ASP.NET Tips: Loading a DLL out of the bin directory
2012-06-29 19:46 mleader1 阅读(290) 评论(0) 编辑 收藏 举报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.