外部程序集的位置

外部程序集的位置

本文介绍了.Net程序集覆盖Assembly.GetExecutingAssembly()。CodeBase /外部程序集的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目设置中引用了一个外部程序集DLL(例如,将其复制到c:\project\abc.dll中)。当我从该程序集中调用导出的方法时,出现运行时错误。因为它正在寻找c:\ABC中的文件abc.ini,而.exe错误消息说它在c:\project中找不到abc.ini

I have a reference to an external assembly DLL (say I copy it in c:\project\abc.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

程序集似乎正在寻找由abc.ini返回的Assembly.GetExecutingAssembly()。CodeBase或Assembly.GetExecutingAssembly()。Location返回的文件夹。

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 /外部程序集的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 02:09