Visual Studio’s resource editor fails to open a Form because the class is not the first class in the header file (C++/CLI)

Suppose you have a following header file and tries to open it in the resource editor of Visual Studio.

namespace Ambiesoft {
	using namespace System;
 
	ref class EncComboItem;
	ref class CSearchURL;
 
	ref class AddHttpDicDialog : public System::Windows::Forms::Form
	{
		...
	}
}

You might have an error like this.

The forward references (ref class) causes this. To fix this, separate them into another files.

In headerref.h (newly created)

#pragma once
namespace Ambiesoft {
	ref class EncComboItem;
	ref class CSearchURL;
}

In the original header,

#include "headerref.h"
 
namespace Ambiesoft {
	using namespace System;
 
	ref class AddHttpDicDialog : public System::Windows::Forms::Form
	{
		...
	}
}

Leave a comment

Your email address will not be published. Required fields are marked *