Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Problem:
There is a process that had loaded a .NET DLL(say foo.dll) when the process start up. In another folder(say FooFolder), I got an exactly same foo.dll (same name, same version and same public token). I know if I use Assembly.LoadFrom() to load the FoolFolder/foo.dll, the FoolFolder/foo.dll will not be loaded by loader and there is only one foo.dll in the current domain.
However if I use Assembly.LoadFile() to load FoolFolder/foo.dll, the DLL was loaded successfully, but when I try to execute the code in FoolFolder/foo.dll, I will get exception of could not load "log4net.dll". (foo.dll reference the log4net.dll).

Question:
Is there any approach to load exactly same DLL in one app domain successfully? or it is impossible in .NET platform?
Posted
Comments
Rob Philpott 28-Aug-14 4:41am    
Have to ask - why? [Edit] I believe not, but being so weird I've never tried.

I believe you don't need to do any such thing. The problem you are facing is that your code is unable to locate log4net.dll. Either the implementation is not correct or else the said dll (log4net.dll) is unavilable in the folder.
 
Share this answer
 
Comments
E.Diao 28-Aug-14 21:28pm    
Thanks Mayank. First, log4net.dll is available in the folder. I do not know the underlying difference between Assembly.LoadFrom and Assembly.LoadFile. MSDN does not give too much comments.
1) Why do you have foo.dll in two instances?
2) You can embed another assambly in the executable, is you want. See: ILMerge[^]
3) Consult MSDN[^], and see how .net locates assamblies. Eslecially this one: http://msdn.microsoft.com/en-us/library/15hyw9x3(v=vs.110).aspx[^]. Please note, that there is a log and a log viewer you can use to track resolution (see: http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspx[^]9.
 
Share this answer
 
Comments
E.Diao 28-Aug-14 21:29pm    
Thanks Zoltan, the tools and document from MSDN is helpful.

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