2

我想知道是否有某种方法可以知道 .csproj 文件中列出的 dll 的完整路径。

对我来说最有趣的是解析默认 dll 的路径,如 System.Xml.dll、System.Data.dll 等。

在 .csproj 文件中只有短名称的行:

<Reference Include="System.Xml.Linq">
  <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
  <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />

我应该查看 $PATH 变量并尝试解析给定的 dll 名称吗?或者是什么 ?

4

2 回答 2

1

The first place you would check is the GAC. If the reference is not in the GAC, then most often there will be a relative or absolute path below the Reference like this:

<Reference Include="mydll">
  <HintPath>..\..\mydll.dll</HintPath>
</Reference
于 2010-02-11T14:08:48.250 回答
1

If its any .NET library like you examples then they will generally be in the following folder: C:\Windows\Microsoft.NET\Framework\< .net version >\ or whaterver is specified in the GAC. Otherwise there will be a HintPath which will be a relative path to your current folder.

于 2010-02-11T14:10:42.177 回答