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

I am using a dll say MyDll.dll.
I want add load this dll programtically without using adding its reference.
But its not letting me to implement the interface present in the dll with adding its reference.

Is there any way of doing it??

You can use Assembly.Load[^] and then reference the classes via reflection - but it's a fair amount of work and you can't use class names directly in your code in the usual way.

If you want to say things like:
MyAssembly.MyClass mc = new MyAssembly.MyClass();
Then you have to add a reference.
Share this answer
Sergey Alexandrovich Kryukov 22-Aug-14 12:02pm    
Assembly.Load? Do you think there is a strong name? Most likely, it will be Assembly.LoadFrom...
Or it can be a native DLL, also a solvable problem...
Abhinav S 22-Aug-14 12:41pm    
nikita2410 23-Aug-14 2:37am    
But how will i implement the interface present in the dll.
OriginalGriff 23-Aug-14 2:42am    
As far as I know, you can only add an interface at compile time - certainly, it would be extremely difficult to add it via reflection.

Add a reference to the DLL: it's going to make your life a lot, lot simpler!
Why don't you want to add it?
Share this answer
Sergey Alexandrovich Kryukov 22-Aug-14 12:03pm    
This solution is totally irrelevant to the question, which you simply did not understand. The answer is to use reflection.

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