using HWND in C++ CLR build error (.NET core 8)
cebuhax0r
66
Reputation points
I have a C++ CLR that contains windows forms on it, the project is a C++ CLR DLL, somewhat related to this: https://video2.skills-academy.com/en-us/answers/questions/1745336/porting-c-clr-net-framework-winform-to-net-8
however, when I declare a variable for native HWND, without even using it. I get the following build error
1>C:\dump\ProjectMigrateNet8\WinformDLL\MyForm.h(19,3): error C2327: 'System::Windows::Forms::Control::HWND': is not a type name, static, or enumerator
here is the code
#pragma once
#include <wtypes.h>
namespace WinformDLL {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
private:
HWND m_window;
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->SuspendLayout();
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(509, 211);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
}
#pragma endregion
};
}
I already added the following framework references in the project file
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WPF" />
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" />
The thing is, Im doing this as I am porting a C++ CLR project that uses HWND in some place, i created the above code just to test.
How do I resolve the issue?
Sign in to answer