问题描述
我写它是由第三方应用程序(的的FitNesse 的框架的测试运行,该DLL是一个测试夹具)。
I am writing a DLL which is loaded by a third party application (The FitNesse framework's test runner, the DLL is a test fixture).
该DLL有它自己的App.config文件(说MyDll.dll.config),我可以告诉FitNesse的加载该App.config文件。
The DLL has its own App.config file (say MyDll.dll.config), and I can tell FitNesse to load that App.config file.
但这里有一个问题:App.config文件包含自定义配置节处理程序,像这样的:
But here's the problem: The App.config file contains custom config section handler, like this:
<configuration>
<configSections>
<sectionGroup name="myGroup">
<section name="MySection" type="MyNamespace.MyHandler.MySection, MyNamespace.MyHandler"/>
...
</sectionGroup>
</configSections>
...
</configuration>
每当App.config文件被读取时,我得到一个异常说,MyNamespace.MyHandler组件无法找到,虽然它坐落在同一文件夹中MyDll.dll.config文件中读取:
Whenever the App.config file is read, the I get an exception saying that the MyNamespace.MyHandler assembly cannot be found, although it sits in the same folder as the MyDll.dll.config file being read:
System.TypeInitializationException: 的类型初始 MyNamespace.MyHandler.MySection 引发了异常。 ---> System.Configuration.ConfigurationErrorsException: 发生创造了一个错误 配置节处理程序 为myGroup / MySection:无法加载文件 或组装MyNamespace.MyHandler或 它的一个依赖。系统 找不到指定文件
我可以看到,该系统会在同一个文件夹中被加载我的DLL的可执行文件位于此文件。不过,我不希望我的文件复制到该第三方目录,反之亦然。
I can see that the system looks for this file in the same folder where the executable that is loading my DLL is located. However, I do not want to copy my files into this third party directory or vice versa.
有没有一种方法来指定系统应查找DLL文件除preT App.config文件?一般的解决方案或FitNesse的特定解决方案将既为我工作。
Is there a way to specify where the system should look for the DLLs to interpret the App.config file? A general solution or a FitNesse-specific solution would both work for me.
非常感谢您的任何帮助!
Thanks a lot in advance for any help!
推荐答案
您可以尝试使用运行时部分按如下说明:
You could try using the runtime section as explained here:
http://kbalertz.com/897297/consume-assemblies-located-folder-different-application-folder-Visual-Basic.aspx
这篇关于正确定位的DLL App.config中节处理程序组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!