views:

42

answers:

2

Hi,

I am using the propertygrid with a class and associated type converter. When I moved the class and the TypeConverter to a dll, it seems that it is not being called. Can't find how to activate the typeconverter from a dll.

Assembly a = Assembly.LoadFile(modulepath + elementname + ".dll");
try
{
    object myobj = a.CreateInstance(objectname);            
    Type objecttype = myobj.GetType();
}

Appreciate any hints. Thank you.

+1  A: 

Do you have something like this in place on your class:

   [TypeConverter(typeof(MyClassConverter))]
 public class MyClass {
    // Insert code here.
 }

Usually as long as the class has the typeconverter associated with it it should pick it up.

Joshua Cauble
A: 

It could be because Assembly.LoadFile loads the file in a different binding context from the rest of your code.

erikkallen
Thanks erikkallen.This pointed me to the right direction.I found the solution herehttp://ayende.com/Blog/archive/2006/05/22/SolvingTheAssemblyLoadContextProblem.aspx
tdolphin