I <3 Steve McConnell*
Coding Horror
programming and human factors
by Jeff Atwood

November 15, 2004

Multiple /bin folders in ASP.NET

About a week ago, Scott Hanselman posted a neat tip on deploying multiple /bin folders in an ASP.NET application. What's really cool about this is that it lets you build a pseudo plugin architecture into your existing ASP.NET website.

Scott documents it perfectly; I'm here to tell you that I tried it, and it works. In my case the folder structure was like so:

screenshot of web folder structure

As you can see, I added a pre-compiled utility WebFileManager to the existing Linktron5000 website by dropping it into a subfolder, binaries and all. To get this to work, all I had to do was make one small change to the parent app Web.config:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <probing privatePath="WebFileManager/bin" />
  </assemblyBinding>
</runtime>

This sets up the probing path for the child assemblies. If you don't do this, you'll get "Assembly not found" exceptions. You also have to make a slight modification to the child .aspx page header, but this modification is safe to make in the original source file and can be permanent:

<%@ Assembly Name="WebFileManager" %>
<%@ Page Language="vb" AutoEventWireup="false"
  Codebehind="WebFileManager.aspx.vb" Inherits="WebFileManager.WebFileManager"%>

Note that I didn't need the additional namespace page directive because this assembly has no namespace. Great tip, Scott. Recommended!

Posted by Jeff Atwood    View blog reactions
« When Good Comments Go Bad
Web Farms and ASP.NET ViewState »
Comments

Hi Jeff, This solution is just what I have been searching for, except... I get the following error:

Parser Error Message: Access is denied: 'adminorders'.

Source Error:


Line 1: <%@ Assembly Name="adminorders" %>
Line 2: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb" Inherits="adminorders.test"%>
Line 3: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Source File: c:\inetpub\wwwroot\cdms\adminorders\test.aspx Line: 1

Assembly Load Trace: The following information can be helpful to determine why the assembly 'adminorders' could not be loaded.


=== Pre-bind state information ===
LOG: DisplayName = adminorders
(Partial)
LOG: Appbase = file:///c:/inetpub/wwwroot/cdms
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===

LOG: Private path hint found in configuration file: adminorders/bin.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: adminorders
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/cdms/6df13855/8934a667/adminorders.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/cdms/6df13855/8934a667/adminorders/adminorders.DLL.
LOG: Attempting download of new URL file:///c:/inetpub/wwwroot/cdms/bin/adminorders.DLL.
LOG: Attempting download of new URL file:///c:/inetpub/wwwroot/cdms/bin/adminorders/adminorders.DLL.
LOG: Attempting download of new URL file:///c:/inetpub/wwwroot/cdms/adminorders/bin/adminorders.DLL.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: adminorders, Version=1.0.2007.25378, Culture=neutral, PublicKeyToken=null

I have seached for ways to solve this and have had no luck. I am on Windowx XP so folder permissions shounldn't really affect this.

Do you have any suggestions to help me get this to work?

Ta
Clive.

Clive on June 30, 2005 8:20 AM

It's the Index Service:

<a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;329065">http://support.microsoft.com/default.aspx?scid=kb;en-us;329065</a>

Jan Wurl on August 15, 2005 6:30 PM

Oh man. Thanks. Same problem. Never would have guessed the indexing service was the problem. Was driving me out of my head.

Chris on April 29, 2006 11:01 AM

ASP.Net - "LOG: Policy not being applied to reference at this time"

Potential Causes/Solutions for this issue I've seen online:
* web server runs out of space --> free up disk space
* aspnet worker process is messed up --> kill aspnet worker process (development environment obviously)
* Indexing Service is running (and locking files) --> disable it
* assemblies are in bin that aren't supposed to be (ref), and the machine.config has an add assembly="*" (all) --> remove unreferenced/unnecessary DLLs from the bin folder.

The last bullet is what I ran into - I removed the DLLs (named "Copy of dllNameHere.dll") from the bin folder and voila! my web service worked. I never saw this fix anywhere, so I'm posting it. Hope it helps.

Matthew Hughes
Systems Developer, MCSD
Program Director, LANUG
http://www.loweraldotnet.org

mat_hues on July 18, 2006 11:28 AM

Mat, the last one fixed the problem for me. I deleted all the dlls from the bin, and then readded them and everything worked. Thanks.

Patrick Santry on August 7, 2006 8:06 AM

For me it turned out to be Avira AntiVir. Removing it seems to have fixed the problem. I'll stick with AVG.

Nick on November 29, 2006 5:42 PM

man, i can't believe it: deactivating AntiVir Guard really solved it.

LoneRanger1000 on December 12, 2006 12:51 PM

Same idea without having to modify any file beyond the root web.config:

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath=WebFileManager\bin" />
</assemblyBinding>

<dependentAssembly>
<assemblyIdentity name="WebFileManager" />
</dependentAssembly>
</runtime>

SoftLion on July 3, 2008 1:49 AM

I had the same issue, tried everything suggested on this page and nothing helped.

What did the trick for me is to give ASPNET user full rights to the windows/temp directory.

Go20 on September 30, 2008 10:22 AM

I had the same problem, but i've solved it... thanks a lot!!

Quito, Ecuador

averdesoto on February 18, 2009 8:14 AM






(no HTML)


Verification (needed to reduce spam):


Content (c) 2009 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved.