2016-06-24 49 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是它的安靜的複雜 –