Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,

I want to create an object of MyClass which is inside Commr.MyClass namespace in commr.dll. MyClass implement the ICommr Interface. Following is the code...
Assembly myDllAssembly = Assembly.LoadFile(@"D:\commr.dll");
ICommr valCommr =(ICommr)myDllAssembly.CreateInstance("Commr.MyClass");
string str = valCommr.GetSetting();

But it gives me a error : Unable to cast object of type Commr.MyClass' to type 'LoadAssembly.ICommr'.

Can you please help me to slove this issue ?

Thanks.
Posted

1 solution

You need to ensure that Commr.MyClass implements ICommr interface.
 
Share this answer
 
Comments
LaxmikantYadav 16-Jan-12 3:29am    
Yes, Commr.MyClass implemented ICommr interface.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900