ASP.NET Tips: Loading a DLL out of the bin directory
Question
A customer has created a web project which references a class library project. When deployed to the local machine the web/classes all work fine. When deployed to a ‘shared’ IIS site, the class DLLs exist in the /bin folder, but the web page generates an error:
can’t find file “Documents and settings/….”
when trying to access the class DLL.
Is there a special setup to make the web pages look in its /bin folder?
Answer
There isn’t usually anything needed in order to make this scenario work. But if it isn’t working for you, there are two choices here. If you are in ASP.NET, most likely the cause is that you don’t have the following entry in the machine.config prior to 2.0 and the root web.config file (in the same folder as machine.config) for 2.0 and later:
<compilation>
<assemblies>
<add assembly="*"/>
</assemblies>
</compilation>
The other way to do this, if you aren’t using ASP.NET, is to add the bin directory to your path for the application. The way this is accomplished is with the probing element:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin;bin2" />
</assemblyBinding>
</runtime>
</configuration>
This is documented here: <probing> Element
There has been a situation where neither of these worked. We are still researching that situation and I will update this post when we have another solution.
Comments
Anonymous
July 21, 2008
Hi, I've been trying to figure something very like this. But in my case the probing solutions won't work as I'm developing an addin based solution and wanted to deploy the addon applications in custom folders like ABC/bin and ABCD/bin. I've tried Assembly.LoadFile and such but although the assembly gets loaded into the domain it looks like it doesn't get loaded into the ASP.Net page compiler domain. Any ideas about this scenario?Anonymous
July 22, 2008
Alexandre, So can you explain to me what you mean by that? Where does it need to be that it isnt'? What error do you see?Anonymous
July 22, 2008
The comment has been removedAnonymous
July 26, 2008
My favorite links from the last week (20/07/2008 - 26/07/2008)Anonymous
August 02, 2008
My favorite links from the last week - 5th Week of July 2008Anonymous
August 24, 2008
By inspecting the fusion log we found out that <probing> does NOT work if the <configuration> Tag inside web.config includes the xlmns="http://schemas.microsoft.com/.NetConfiguration/v2.0" attribute.Anonymous
September 24, 2008
I have exactly the same needs. I need to load the assemblies from the addin/bin folder. But couldn't handle how now. The thing I am doing is copy them all to the App's bin directory. But this isn't nice to mix them all together. Anyone as a solution yet?Anonymous
October 13, 2008
CodehighlightingproducedbyActiproCodeHighlighter(freeware)http://www.CodeHighlighter.com/--