Dynamic assembly load -
01-28-2004
, 03:31 PM
Hi everyone!
I have one problem, I cannot solve. The problem is in dynamic load of one assembly from another. I am working with Visual Studio .NET and built one assembly as .exe file. The second assembly is a class library type .dll. I simply trying to load the second assembly, create object from one of the classes defined in it. The constructor of the class in the second assembly has two parameters. It looks like something like this:
class MyClass
{
public MyClass(IMyInterfase Param1, COtherClass Param2)
{
……
}
}
Where IMyInterfase if an interface I defined in both assemblies and COtherClass is a class also defined in both assemblies.
I found problem when I am calling to Activator.CreteInstance and trying to transfer in parameter array some valid values. Of cause, if I creating the object from this class in the same assembly, the result is success.
Call to function Activator.CreteInstance(MyClassType, new object[2] { Param1, Param2}), where Param1 is a IMyInterfase and Param2 is an object of COtherClass class simply returns something like invalid cast exception.
I tried to create object with default constructor and then call to some method, the result was the same. But if instead of my own types IMyInterfase and COtherClass I use some standard types, the result is success.
May be something wrong in my types, by I cannot understand what it is. Please help me in this problem.
Best regards.
Igor |