Click here to Skip to main content
15,605,787 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to load multiple dlls from an application at runtime.
For example like below.

Assembly assembly = Assembly.LoadFrom("MyNice.dll");
Type type = assembly.GetType("MyType");
object instanceOfMyType = Activator.CreateInstance(type);

Assembly assembly = Assembly.LoadFrom("MyAnotherNice.dll");
Type type = assembly.GetType("MyType");
object instanceOfMyType = Activator.CreateInstance(type);

MyNice.dll and MyAnotherNice.dll
are referring to a same library with different versions. Say Reflib.dll and Reflib.dll.

Question : Is this possible and if yes how will the versions of
library reference will get resolved runtime as both the version has significant differences in functionality.

What I have tried:

I have not really tried this,but I have requirement to implement this and I am sure I have such scenario to handle. I am looking for the best practices professionals follow or adopt.
Updated 5-Jan-17 23:34pm

1 solution

In this scenario, I would tend to use separate AppDomains to keep things nice and clean. I have encountered exactly this scenario when I wrote a plugin handler a while back and solved it using AppDomains to load the assemblies and their dependencies.
Share this answer
DIPAK@EMSYS 6-Jan-17 9:06am    
Thank you. I was thinking the same. Only part not clear to me is how do we load the dependencies as well?
Pete O'Hanlon 6-Jan-17 9:09am    
You need to look at this
DIPAK@EMSYS 6-Jan-17 9:12am    
Thank you. Good start for me..:)
Pete O'Hanlon 6-Jan-17 9:20am    
You're welcome. Glad to be of service.

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