views:

399

answers:

5

I've got a web application and a corresponding web.config. The application depends upon assemblies, which are located on the system in a specific path (e.g. c:\programms\myprog\bla.dll) but not registered in the GAC. How can I tell my web application where to find these assemblies it depends upon? I guess I can do that somewhere in the web.config. But how?

Thanks in advance!

+4  A: 

Check this article on Assembly Binding Redirection.

Basically you should add this to your config file:

<runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v1.0.3705">
            <dependentAssembly> 
               * assembly information goes here *
            </dependentAssembly>
       </assemblyBinding>
</runtime>
Gerrie Schenck
A: 

For registering of custom controls and user controls :

<system.web>
    <pages>
      <controls>
        <add assembly="WebApp.CustomControl"
                namespace="WebApp.CustomControls"
                tagPrefix="cc" />
      </controls>
    </pages>
</system.web>

For registering assemblies :

<assemblies>
  <add assembly="WebApp.Util, Version=1.0, Culture=neutral, PublicKeyToken=f573aa5672ce4fd2"/>
</assemblies>

Hope this helps !

Canavar
+1  A: 

You should be using the codebase element as given in http://msdn.microsoft.com/en-us/library/efs781xb(VS.71).aspx, even though article says href, it can be used for local paths also

Dinesh Manne
A: 

Why do you store assemblies in 1 specific location? For debugging purposes? You can also add a hintpath for debugging purposes. Add a file ref to it an make it copy local = true. Assembly lookup will first be local in the debug\bin folder (application base).

Patrick Peters
There are a couple of other applications and services running on the machine. In order to keep things clean, we agreed to store all binaries in a single location. Makes updates easier.
Matthias
Why aren't you using the GAC? Reuse of assemblies is where GAC is there for.
Patrick Peters
A: 

Wherever possible, always store your assemblies in the GAC. It'll behave like the single directory you're using now, with the added advantage of side-by-side deployment!

Ace