How does VS 2008 determine where to look for assemblies used during compiling of applications? There must be some order used. Is there something that is used in the Tools\Settings or something else? I am looking for the order of which assemblies resolution occurs during the compilation process.
Here is a post that looks like it may shed some light on your question... Sorry I didn't have time to get a better answer.
Pretty sure this depends on how you added your references.
I think it goes like this:
- If a GAC reference, look in the GAC
- If a project reference, from build output of project
- If a file reference, looks at file location
If you have a direct reference to some type, then your project won't build unless you reference its containing assembly, so its not like you can just put the files in a common directory and compile. You must explicitly reference the assembly.
Assembly resolution is more of a concern at runtime. At compile time, its pretty deterministic.
It really isn't VS 2008 that determines the order, but rather the compiler. I know you didn't specify a language, but I'll use C# as an example (I'm sure many other languages would serve as good examples too). If you were using C#, the compiler processes csc.rsp (response file located beside csc.exe) first and then processes command-line /r: options. The order of operations determine which assembly is referenced. Therefore, assembly references in csc.rsp are found first and then command-line assemblies are found. This was compile-time.
Here's the docs for the C# response file:
http://msdn.microsoft.com/en-us/library/8a1fs1tb%28VS.71%29.aspx
Here's the docs for C# command-line compiler options:
http://msdn.microsoft.com/en-us/library/2fdbz5xd%28VS.71%29.aspx
You would have to use the command-line compiler if you wanted to use a custom response file. Otherwise, the references you add to a project's references folder determine what appears on the command-line when you build in VS. You can see the order that these references appear on the command-line by doing a build and looking at the Output Window, Ctrl+W+O.
Run-time assembly binding is not determined by VS neither, but rather by the CLR. A quick summarization is that the CLR searches to see if an assembly was previously loaded into memory, the checks the GAC, and then performs probing based on whether there was an explict call to Load in the code, then a config file setting for codeBase, and then a set of folders under the application folder that are named for either exe or dll versions of the assembly. Here's the MSDN link:
http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx
The fact that you're asking this question makes me wonder if your motivation is to solve an assembly binding issue. There is a tool in the .NET Framework SDK, called the Assembly Binding Log Viewer (Fuslogvw.exe) for helping resolve these types of problems:
http://msdn.microsoft.com/en-us/library/e74a18c4%28VS.71%29.aspx
A couple of the best resources on the net for working with assembly bindings and Fusion log viewer are Richard Grimes' Fusion Workshop:
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
A few years back, Suzanne Cook, who was a member of the CLR team, did an excellent series of posts on CLR binding:
http://blogs.msdn.com/suzcook/default.aspx
Hope this helps,
Joe