This is an embarrassing question but I feel like I tried everything for last couple of hours.
I just want to add attribute of following to my property
#using <System.Drawing.dll>
#using <System.Design.dll>
...
using namespace System::Drawing::Design;
using namespace System::Configuration;
using namespace System::ComponentModel;
using namespace System::Windows::Forms::Design;
...
[Editor(typeof(FolderNameEditor), typeof(UITypeEditor))]
property System::String^ DefaultWorkingDirectory;
First, I tried as it is and compiler says “illegal use of the type (FolderNameEditor).
Now I tried this
[Editor(Type::GetType("System.Windows.Form.Design.FolderNameEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"),
Type::GetType("System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"))]
But it says illegal attribute argument.
If I do following, the C++/CLI project compiles
[Editor("System.Windows.Form.Design.FolderNameEditor", "System.Drawing.Design.UITypeEditor")]
But Whenever I tried to get reference of the project from a C# project, I get an error saying the namespace is missing. If I comment out the editor attribute and #using and using namespace above, everything is just fine.
For some reason, I can’t find related materials in MSDN, if you can point out proper document, that would be appreciated.
UPDATE: The C# project was .NET 4 Client Profile and that’s the reason why I got the error indicating missing namespace which is misleading. Changing the target framework to .NET 4 solved the problem.
The C++/CLI equivalent to
typeof()is::typeid. Try this: