Friday, May 18, 2012

ASP.NET: Load DLL’s from another location

By default your application DLL’s in ASP.NET application are loaded from the bin folder. But what if you want to use a different folder?
The application has some default DLL’s in the bin folder, but I want to be able to load my Module DLL’s from the bin\Modules subfolder. (Don’t ask me why Glimlach)
To do this add the following to your web.config(also works for the app.config):
<runtime> 
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
  <probing privatePath="bin;bin\Modules" /> 
 </assemblyBinding> 
</runtime>


Remark: Don’t forget to also add the bin folder to the probing path. First we forgot to do this and our default DLL’s were not loaded.

3 comments:

nobodybutca said...
This comment has been removed by the author.
nobodybutca said...
This comment has been removed by the author.
nobodybutca said...

Hi,

Do you have a working sample project for this problem/issue.

I tried same approach as yours but couldn't make it work.

Taken from;
http://stackoverflow.com/questions/1892492/c-sharp-set-custom-path-to-referenced-dlls?rq=1