我正在尝试ConfigurationSection使用ConfigurationElementCollection. 但是当我使用它时会抛出一个ConfigurationErrorsException带有 2 个详细信息的异常TargetInvocationException并且MissingMethodException
我在构造函数中安慰一些消息,结果只是“新的 AssembySettingSection”。在 AssembySettingSection base["settings"] 处抛出异常。
应用配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="AssembySetting" type="IngoWinService.AssembySettingSection, IngoWinService"/>
</configSections>
<AssembySetting>
<settings>
<add name="IngoWinService.Haier.Service" assemby="IngoWinService.Haier" />
</settings>
</AssembySetting>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
部分代码(需要时发布其他人)
public class AssembySettingSection : ConfigurationSection
{
public AssembySettingSection()
{
System.Console.WriteLine("new AssembySettingSection");
}
[ConfigurationProperty("settings", IsDefaultCollection = false)]
[ConfigurationCollection(typeof(AssembySettingCollection))]
public ConfigurationElementCollection Settings
{
get
{
return base["settings"] as AssembySettingCollection;//Throw Exception
}
}
}
12345678_0001
相关分类