views:

216

answers:

3

I have a few .Net assemblies, same version, same file name, but located at different location:

  1. Program folder
  2. C:\Windows
  3. C:\Windows\system32
  4. GAC

Now, which location's assembly will be loaded first?

A: 

This looks like a reasonable explanation: http://www.ondotnet.com/pub/a/dotnet/2003/03/17/bindingpolicy.html

On MSDN the following may be relevant too: http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx

jerryjvl
A: 

.Net assemblies has different search order than regular windows .dll. GAC will be checked the first thing ONLY if the assembly is strongly named signed. If the assembly is not in the gac / not strong name signed , the local folder is checked after that. That is the end of the .net assembly search order, 1,2 and 3 above are not checked.

you can change where the .net looks for assembly by having a local configuration file for you app.

Also, this post contain very useful information http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/5eac976e91a5547a/44ee27d9289841f7?lnk=st&q=assembly%2Bsearch&rnum=1

mfawzymkh
A: 

C:\Windows and C:\Windows\System32 are not of relevance for managed assembly probing. The framework won't look for assemblies there.

It looks first in the GAC/Application Folder and then in folders pointed to by the codebase/privatepath settings if specified in the App.Config file. (Only strong-named assemblies can be placed in the GAC.) While probing it checks for multiple combinations by appending .dll or .exe, looking in folders named assembly.exe/.dll, looking for assemblies targeted for specific cultures if required.

A good tool to see which folders the runtime checked for assembly resolution failures is the Fusion Log Viewer. Enter 'fuslogvw' at the VS Command Prompt. It shows entries keyed by ApplicationName and Name

Gishu