Search code examples
c#.netwinformsvisual-c++designer

.Net Designer assemblies, C++\C# error


I'm working on an designer-heavy application (using Visual C++ 2.0, but a C# solution should still be relevant). My setup is this:

I have a UserControl named "Host" I'm attempting a UserControl named "Child"

Child contains a property to a class whose type is defined in a different dll entirely, named "mytools.dll"

Child works just fine in the designer. However, when I go to drag "child" onto "host" from the designer, I get the following error:

Failed to create component 'Child'.  The error message follows:  'System.io.filenotfoundexception: could not load file or assembly MyTools, Version XXXXXX, Culture=neutral
.....
{unhelpful callstack}

If I comment out the property in "child" that points to the class in mytools.dll, everything designs just peachy. I have the property marked with "Browsable(false), and DesignerSerializable(hidden), and it does not help.

Is there a way for me to explicitly say "Don't load this dll, you won't need it in design time", or some way for me to force a dll to load from the designer programmatically?

Thanks!


Solution

  • If the property is marked 'public' then the UserControl will force the designer to load the external assembly.

    You must rework your control to return Object instead of the bad type, and do typecasting if you must keep it public, otherwise, protected should be fine.