gpt4 book ai didi

c# - 正确定位 DLL 的 App.config 部分处理程序程序集

转载 作者:太空宇宙 更新时间:2023-11-03 14:25:13 26 4
gpt4 key购买 nike

我正在编写一个由第三方应用程序加载的 DLL(FitNesse 框架的测试运行器,DLL 是一个测试夹具)。

DLL 有自己的 App.config 文件(比如 MyDll.dll.config),我可以告诉 FitNesse 加载那个 App.config 文件。

但这就是问题所在:App.config 文件包含自定义配置部分处理程序,如下所示:

<configuration>

<configSections>
<sectionGroup name="myGroup">
<section name="MySection" type="MyNamespace.MyHandler.MySection, MyNamespace.MyHandler"/>
...
</sectionGroup>
</configSections>
...
</configuration>

每当读取 App.config 文件时,我都会收到一个异常,指出找不到 MyNamespace.MyHandler 程序集,尽管它与正在读取的 MyDll.dll.config 文件位于同一文件夹中:

System.TypeInitializationException: The type initializer for 'MyNamespace.MyHandler.MySection' threw an exception. ---> System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for myGroup/MySection: Could not load file or assembly 'MyNamespace.MyHandler' or one of its dependencies. The system cannot find the file specified

我可以看到系统在加载我的 DLL 的可执行文件所在的同一文件夹中查找此文件。但是,我不想将我的文件复制到这个第三方目录中,反之亦然。

有没有办法指定系统应该在哪里寻找 DLL 来解释 App.config 文件?通用解决方案或特定于 FitNesse 的解决方案都适合我。

非常感谢您的帮助!

最佳答案

关于c# - 正确定位 DLL 的 App.config 部分处理程序程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4284995/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com