R
Romain TAILLANDIER
hi group
I have an application where i dynamicly load a dll.
this dll contain a class MyClass and an interface IMyClass
my application contain the IMyClass interface too.
[dll : ]
interface IMyClass{...}
class MyClass : IMyClass{...}
[MyApp : ]
interface IMyClass{...}
in my code, i want to create an instance of MyClass.
i use a code like that :
Assembly assem = Assembly.Load(this.DllName);
Type MyType = assem.GetType("MyClass");
Object obj = Activator.CreateInstance(myType);
MethodInfo myMethode = myType.GetMethod("createInstance");
//this 4 lines works !
// MyClass :: createInstace, return a MyClass instance
IMyClass instance = (IMyClasse)myMethode.Invoke(obj,null);
// this last line does'nt work because of the cast , naturally...
I need to do exactly this, but it can't work because the type MyClass is
only define on the dll :
MyClass instance = myMethode.Invoke(obj,null);
I don't see any solution ....
Please save me !!
ROM
I have an application where i dynamicly load a dll.
this dll contain a class MyClass and an interface IMyClass
my application contain the IMyClass interface too.
[dll : ]
interface IMyClass{...}
class MyClass : IMyClass{...}
[MyApp : ]
interface IMyClass{...}
in my code, i want to create an instance of MyClass.
i use a code like that :
Assembly assem = Assembly.Load(this.DllName);
Type MyType = assem.GetType("MyClass");
Object obj = Activator.CreateInstance(myType);
MethodInfo myMethode = myType.GetMethod("createInstance");
//this 4 lines works !
// MyClass :: createInstace, return a MyClass instance
IMyClass instance = (IMyClasse)myMethode.Invoke(obj,null);
// this last line does'nt work because of the cast , naturally...
I need to do exactly this, but it can't work because the type MyClass is
only define on the dll :
MyClass instance = myMethode.Invoke(obj,null);
I don't see any solution ....
Please save me !!
ROM