开发者

In Visual Studio, how can I see if an assembly is refenced from the GAC?

Simple question: In Visual Studio, how can I see whether an assembly is referenced from the GAC or whether the reference is simply referenced through the ('no开发者_StackOverflow社区rmal') file system?

I thought I'd be able to deduct this by looking at the .csproj file but maybe not. Here's an outtake from my .csproj-file:

<Reference Include="MoreLinq, Version=1.0.11522.0, Culture=neutral, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\lib\MoreLinq.dll</HintPath>
</Reference>
<Reference Include="Oracle.DataAccess, Version=9.2.0.401, Culture=neutral, PublicKeyToken=89b483f429c47342">
  <SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />

I know that Oracle.DataAccess and System is referenced from the GAC and MoreLing (thanks Jon!) is referenced through the file system. The only difference I can see is that MoreLinq has a HintPath value. Is that what distinguishes a GAC reference from a file reference? In any case I can't see this in VS

Since this has a big impact on how assemblies are loaded, I would assume this information would be easy to get to, but I may be wrong?


I think that you can't know this for sure without running the program. If the 'Copy local' property of the reference is set to False, it shows that the DLL comes from the GAC. But remember that the GAC has priority over the rest of the file system (including the current directory).

At run-time, you can be sure through the Debug / Windows / Modules window, where you can see the exact path of the loaded DLL.


I'm not an expert, but as I understand it, the difference between the two references that you show in the question is only for build time. At runtime, the system will use whatever dlls it finds - starting in the GAC, then looking in the same folder as your executable. This means that you can't determine at design or compile time which it will be when the program is actually run.

(By the way, AFAIK Visual Studio doesn't compile anything using dlls from the GAC. This can sometimes cause confusion because what you see at design/build time (local dlls) doesn't correspond to what may be in the GAC at runtime).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜