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

查看:110
本文介绍了(物理)(已安装)路径的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.

I需要获取实际安装实际dll的路径 - 或VS的bin / debug或(release)文件夹。

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文件夹会被剪切掉(但是.Net版本被修改为通过ClickOnce安装,可以使用Clickonce数据文件夹))

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.GetExecutingAssembly c $ c> 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天全站免登陆