2016-06-24 47 views
0

我无法理解Visual Studio将依赖关系解析为.NET dll的机制。在一些.csproj文件中,我有一些依赖关系,如下所示。了解DLL地狱

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

然而,HintPath指向一个无效的路径,但Visual Studio中能够根据需要,显然是从其他地方走的DLL构建和部署项目。在我的情况下,这不是一个主要问题,因为最终结果是按照需要的,但我最终不明白哪个机制对.NET dll的依赖性得到解决。

如何在构建Visual Studio项目时查明实际引用了哪个dll? dll允许的位置是什么?

+1

这是否回答你的问题:(http://stackoverflow.com/questions/49972/in-what-order-are-locat离子搜索到负载参考dlls) –

+0

@KevinWallis是的,有点,谢谢你的参考。然而,第二个想法是,它没有;基本上答案都是“这取决于”。 – Codor

回答

1

您可以使用下面的代码,以确定所有加载的程序集,并检查它们的路径:从岗位

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); 
} 

Determine Loaded Assemblies

这里是“如何在运行时的文件定位程序集”

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

+0

接受为明确答案,因为链接显然是最全面的来源;不过,我希望事情不会那么复杂。 – Codor

+1

@Codor是它的安静的复杂 –