Where are assemblies in .NET physically located?

Viewed 25408

I am a little confused about where .NET assemblies are physically located. Take good old LINQ. In my web.config file it says:

<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

This is the reference to LINQ. But where exactly is the DLL this refers to located? There isn't any path in the above and it's not in my bin folder.

I also have what I think is a third-party assembly reference:

<add assembly="MapInfo.CoreTypes, Version=4.0.0.483, Culture=neutral, PublicKeyToken=F548BCBA69D4B8DA" />

How can I tell where this is located on my machine if it's not in the bin folder?

Also, if a DLL file is in the bin directory, can I assume that it doesn't need to be referenced in web.config?

6 Answers

Assembly and Fusion path probing is pretty complicated. I will say that typically .NET will resolve an assembly from one of two places:

  1. Either it will find it in local directory, like the current directory, a bin subdirectory, or other place specified by the Fusion assembly-binding logic, or

  2. it will find it in the global GAC store, where assemblies can be registered and looked up by name, version, and a couple other attributes.

To address your specific question about the 'bin' directory, if you're using ASP.NET (which I assume from your reference to web.config), then yes, you don't need to include the path - ASP.NET will take care of whatever it needs to do in order to make .NET look for assemblies in the 'bin' directory.

The short answer is: it depends on alot of things. The framework has its rules for how it loads assemblies. However, you can override this using the various config files (machine.config, etc). To find out where your assemblies actually live on a particular system, use the Assembly Binding Log Viewer. (It's part of the platform SDK. Just open up an SDK command shell and run fuslogvw.exe.)

An assembly can be found mostly in either of the following places:

  • GAC - C:\Windows\Assembly\GAC (Microsoft provided and by third-party in some cases)
  • Installation folder (most of the third-party controls)

You can get path and other information about an assembly by right clicking on the assembly in your project references and selecting Properties.

Related