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:
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!