SaphuA

Hello,

I've made a Control that uses reflection to show other Controls in a menu-type way. During Design time you can add pages to the collection. Each page has a Property with a name of the Control it is linked with. The Control is developed to use reflection to convert this String to an actual instance of the Control.

The Control is part of a framework I am developing and is thus referenced in another project. Everything works like a charm during Design time. But when I run the project the code below throws an exception:

Type type = Type.GetType(name);

Where name is: "DirectDemo.UserControl1"

Does this mean that the framwork doesn't have acces to the Control in the other project

Kind regards,



Re: Visual C# General Assembly only has acces during Design time

TaylorMichaelL

Reflection works fine across assemblies. The question is how are you accessing the other project. Presumably you have an assembly with the UC in it. Is the assembly loaded into your project when you try to make the above call If not then it'll fail as the loader has no way of knowing where the type is defined. To force the loader to load the assembly, if needed, you need to pass the full assembly name as well, such as: DirectDemo.UserControl1,MyTestAssembly.

Michael Taylor - 10/8/07

http://p3net.mvps.org





Re: Visual C# General Assembly only has acces during Design time

SaphuA

Awesome, thanks a lot!

Using "DirectDemo.UserContrl1,DirectDemo" fixed it for me.

I'm still curious as to why it worked during Design time and not during Run time though.

Kind regards,





Re: Visual C# General Assembly only has acces during Design time

TaylorMichaelL

Once you drop the control on a form the designer loads the assembly for you. At runtime it won't load it until the form loads. That would be my only rationalization for why it works in design mode.

Michael Taylor - 10/8/07

http://p3net.mvps.org