在可执行文件中定义的自定义配置部分
问题描述:
我在本节中为相同的可执行程序集(IVITerminal.exe
)定义了自定义配置节类。在App.config中我有:在可执行文件中定义的自定义配置部分
<configSections>
....
<section name="myconfig" type="IVITermital.Configuration.Section, IVITerminal"/>
....
</configSections>
....
<myconfig>....</myconfig>
但是,当我想读部分:
static void Main(string[] args)
{
var s = ConfigurationManager.GetSection("myconfig") as Section;
我System.Configuration.ConfigurationErrorsException
类型的异常Could not load type 'IVITermital.Configuration.Section' from assembly 'IVITerminal'.
。
是否可以在同一个exe中定义配置节?
答
该错误通常意味着文件中存在某种语法错误。即放置错误,拼写错误或未封闭的部分。
是否存在内部异常?
MSDN文档描述的格式如下:
<configuration>
<!-- Configuration section-handler declaration area. -->
<configSections>
<sectionGroup name="pageAppearanceGroup">
<section
name="pageAppearance"
type="Samples.AspNet.PageAppearanceSection"
allowLocation="true"
allowDefinition="Everywhere"
/>
</sectionGroup>
<!-- Other <section> and <sectionGroup> elements. -->
</configSections>
<!-- Configuration section settings area. -->
</configuration>
谢谢你这是在类名错字 – shibormot