0

I have trouble understanding the mechanisms by which Visual Studio resolves dependencies to .NET dlls. In some .csproj file, I have some dependency as follows.

<Reference Include="SomeDependency,
                    Version=SomeVersion,
                    Culture=neutral,
                    PublicKeyToken=SomePublicKeyToken,
                    processorArchitecture=MSIL">
    <SpecificVersion>False</SpecificVersion>
    <HintPath>SomeHintPath</HintPath>
</Reference>

However, the HintPath pointed to an invalid path, yet Visual Studio was able to build and deploy the project as desired, apparently taking the dll from somewhere else. In my case, this wasn't a major problem as the final result was as desired, but I ultimately do not understand by which mechanism dependencies to .NET dlls are resolved.

How can I find out which dll is actually referenced when building a Visual Studio project? What are the permitted locations for dlls?

Codor
  • 17,447
  • 9
  • 29
  • 56
  • 1
    Does this answer your question: (http://stackoverflow.com/questions/49972/in-what-order-are-locations-searched-to-load-referenced-dlls) – wake-0 Jun 24 '16 at 09:06
  • @KevinWallis Yes, sort of, thanks for the reference. However on second thought, it does not; basically the answers are stating that "it depends". – Codor Jun 24 '16 at 09:10

1 Answers1

2

You can use the following code to determine all loaded assemblies and also check the path of them:

AppDomain ad = AppDomain.CurrentDomain;
Assembly[] loadedAssemblies = ad.GetAssemblies();

Console.WriteLine("Here are the assemblies loaded in this appdomain\n");
foreach (Assembly a in loadedAssemblies)
{
    Console.WriteLine(a.FullName);
}

from the post (Determine Loaded Assemblies)

And here is the documentation of "How the Runtime Locates Assemblies"

https://msdn.microsoft.com/en-us/library/yx7xezcf(v=vs.110).aspx

Community
  • 1
  • 1
wake-0
  • 3,918
  • 5
  • 28
  • 45