gpt4 book ai didi

c# - 自定义 ConfigurationSection 类型未正确加载

转载 作者:太空狗 更新时间:2023-10-29 22:28:44 27 4
gpt4 key购买 nike

每次我为这个自定义部分执行 ConfigurationManager.GetSection("registeredPlugIns") 时,我都会收到此错误:

为 registeredPlugIns 创建配置部分处理程序时发生错误:

Could not load type 'Engine.PlugInArch.PlugInConfigurationSection' from assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

为什么它试图从 System.Configuration 加载类型而不是我要求它加载的程序集?

这是我的部分代码:

namespace Engine.PlugInArch
{
public class PlugInConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("plugIns", IsDefaultCollection = false),
ConfigurationCollection(typeof(PlugInCollection), AddItemName = "addPlugin")]
public PlugInCollection PlugIns
{
get { return this["plugIns"] as PlugInCollection; }
}

}
}

这是我的 app.config

<configuration>
<configSections>
<section name="registeredPlugIns" type="Engine.PlugInArch.PlugInConfigurationSection, Engine"/>
</configSections>
...
<registeredPlugIns>
<plugIns>
<addPlugIn DllName="ProcessorPlugin.dll"/>
</plugIns>
</registeredPlugIns>

</configuration>

最佳答案

你的dll叫Engine.dll吗?我认为不是,这就是问题所在。

好的,从 sysinternals 运行 procmon。将过滤器设置为您的进程名称,并过滤结果 =“未找到名称”。您将看到它正在寻找 Engine.dll 或 Engine.exe 的条目。查看它在哪里寻找它,很可能需要将文件复制到正在运行的文件夹。

关于c# - 自定义 ConfigurationSection 类型未正确加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4269075/

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