Clarification needed: How does .NET runtime resolve assembly references from parent folder?
- by aoven
I have the following output structure of executables in my solution:
%ProgramFiles%
|
+-[MyAppName]
|
+-[Client]
| |
| +-(EXE & several DLL assemblies)
|
+-[Common]
| |
| +-[Schema Assemblies]
| | |
| | +-(several DLL assemblies)
| |
| +-(several DLL assemblies)
|
+-[Server]
|
+-(EXE & several DLL assemblies)
Each project in solution references different DLL assemblies, some of which are outputs from other projects in solution, and others are plain 3rd-party assemblies. For example, [Client] EXE might reference an assembly in [Common], which is in a different directory branch.
All references have "Copy Local" set to false, to mirror the layout of the files in the final installed application.
Now, if I take a look at reference properties in the Visual Studio IDE, I see that "Path" of every reference is absolute and that it corresponds to the actual output location of the assembly. That's understandable and correct. As expected, solution compiles and runs just fine.
What I don't understand is, why everything seems to work even when I close the IDE, rename the [MyAppName] directory and run the [Client] EXE manually? How does the runtime find the assemblies if the reference paths aren't the same as they were at the time of linking?
To be clear - this is actually exactly what I'm after: a semi-dispersed set of application files that run fine regardless of where the [MyAppName] directory is located or even what it's named. I'd just like to know, how and why this works without any specific path resolution on my part.
I've read the answers to this similar question, but I still don't get it.
Help much appreciated!