.Net 程序集覆盖外部程序集的 Assembly.GetExecutingAssembly().CodeBase/Location [英] .Net assembly override the Assembly.GetExecutingAssembly().CodeBase/Location of an external assembly
问题描述
我在项目设置中有对外部程序集 DLL 的引用(假设我将它复制到 c:projectabc.dll).当我从该程序集中调用导出的方法时,我收到运行时错误.因为它正在寻找一个位于 c:ABC 中的文件 abc.ini 而 .exe 错误消息说它在 c:project
I have a reference to an external assembly DLL (say I copy it in c:projectabc.dll) in the project setting. When I make a call to the exported method from that assembly I get runtime error. Because it is looking for a file abc.ini which is in c:ABC while the .exe error message saying that it cannot find the abc.ini in c:project
程序集似乎在寻找由 Assembly.GetExecutingAssembly().CodeBase 或 Assembly.GetExecutingAssembly().Location 返回的文件夹以获取 abc.ini.
The assembly seems looking for the folder returned by either Assembly.GetExecutingAssembly().CodeBase or Assembly.GetExecutingAssembly().Location for the abc.ini.
如何仅愚弄"他的装配位置在 c:ABC 的装配?
How to 'fool' only that assembly his assembly location is at c:ABC?
推荐答案
没有合理的方法来更改 GetExecutingAssembly.CodeBase
或 Location
.如果您没有相关程序集的源代码,您唯一的解决方案是将您的程序集复制到 c:ABC
There's no reasonable way to change GetExecutingAssembly.CodeBase
or Location
. If you don't have source for the assembly in question, your only solution is to copy your assembly to c:ABC
这篇关于.Net 程序集覆盖外部程序集的 Assembly.GetExecutingAssembly().CodeBase/Location的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!