Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify the exact location of an assembly in a config file

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!

like image 332
Mats Avatar asked Mar 03 '09 08:03

Mats


People also ask

Where are assemblies stored?

Static assemblies are stored on disk in portable executable (PE) files. Static assemblies can include interfaces, classes, and resources like bitmaps, JPEG files, and other resource files. You can also create dynamic assemblies, which are run directly from memory and aren't saved to disk before execution.

What is location path in web config?

The path attribute defines the site or virtual directory that the configuration settings cover. To specify that the settings in the <location> element apply to the default Web site, set the path attribute to Default Web Site .

Where does .NET look for assemblies?

For strong-named assemblies, the binding process continues by looking in the global assembly cache. The global assembly cache stores assemblies that can be used by several applications on a computer. All assemblies in the global assembly cache must have strong names.


4 Answers

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>
like image 97
Gerrie Schenck Avatar answered Oct 25 '22 13:10

Gerrie Schenck


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

like image 23
Dinesh Manne Avatar answered Oct 25 '22 13:10

Dinesh Manne


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).

like image 34
Patrick Peters Avatar answered Oct 25 '22 13:10

Patrick Peters


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!

like image 36
Ace Avatar answered Oct 25 '22 12:10

Ace