DLL(物理)(安装)路径安装到GAC [英] (Physical)(Installed) path of DLL installed to the GAC

查看:209
本文介绍了DLL(物理)(安装)路径安装到GAC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能得到所(可能)登记在GAC一个DLL的(物理)安装路径?此DLL是可以在比.net应用程序中其他的东西来承载的控制(包括VS比其他IDE ...)。

How can I get the (physical) installed path of a DLL that is (may be) registered in GAC? This DLL is a control that may be hosted in things other than a .Net app (including IDEs other than VS...).

当我使用的System.Reflection。 。Assembly.GetExecutingAssembly()的位置,它提供了在winnt\system32 GAC文件夹路径 - 或者设计VS模式使得路径VS IDE

When I use System.Reflection.Assembly.GetExecutingAssembly().Location, it gives path of GAC folder in winnt\system32 - or in Design mode in VS gives the path to the VS IDE.

我需要得到身体的地方dll是实际安装路径 - 或者斌/调试或(释放)文件夹VS.

I need to get the path where physical dll is actually installed - or the bin/debug or (release) folder for VS.

原因是,有我需要在此文件夹中的XML文件,与那些无论是在设计模式,并在运行时使用的配置设置。

Reason is that there is an XML file I need to get at in this folder, with config setting that are used both in design mode and at runtime.

或者它是如何最好地处理这种情况?我有我目前使用设计模式的一个可疑的网络位置......(不要以为的ApplicationData文件夹被削减它(但因为这是通过ClickOnce的ANS可以使用的ClickOnce安装数据.NET版本soved文件夹))

Or how is it best to handle this scenario? I have a dubious network location I am using for design mode at the moment... (Don't think that ApplicationData folder is going to cut it (but have the .Net version soved as that's installed via ClickOnce ans can use the Clickonce Data folder) )

推荐答案

如果把的东西在GAC得到,它实际上被下%WINDIR%\assembly复制到一个点像

If something gets put in the GAC, it actually gets copied into a spot under %WINDIR%\assembly, like

C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll

我假设你看到类似的东西,当你检查的位置装配有问题,当它安装在GAC。这实际上是正确的。 (在.NET 1.1有一个代码库当你看着一个GAC程序集的属性中列出,但这只是向您展示在原始文件位于当您运行GACUTIL - 它实际上并没有指出哪些会被加载。 )你可以阅读更多关于这里

I assume you're seeing something like that when you check the Location of the assembly in question when it's installed in the GAC. That's actually correct. (In .NET 1.1 there was a "Codebase" listed when you looked at a GAC assembly's properties, but that was only to show you where the original file was located when you ran gacutil - it didn't actually indicate what would be loaded.) You can read more about that here.

长话短说,你可能无法做你想做的事情。而不是寻找就该是加载某些组件( Assembly.GetExecutingAssembly()),你可能要切换的行为看起来相对主应用程序组件( Assembly.GetEntryAssembly()),或者把文件中的某些众所周知的位置,可能是基于被设置环境变量。

Long story short, you may not be able to do what you want to do. Instead of looking in relation to some assembly that's being loaded (Assembly.GetExecutingAssembly()), you might want to switch the behavior to look relative to the primary application assembly (Assembly.GetEntryAssembly()) or put the file in some well-known location, possibly based on an environment variable that gets set.

这篇关于DLL(物理)(安装)路径安装到GAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆