我有以下代碼如何解決「無法識別的元素'elementName'。(line x)(line x)」?
var section = new CustomConfigurationSection();
section.SectionInformation.Type = "System.Configuration.NameValueFileSectionHandler";
section.SectionInformation.SetRawXml(sectionXml);
configuration.Sections.Add(sectionName, section);
最後一行其中拋出:
ConfigurationErrorsException錯誤 發生執行用於顯示器的配置 部的處理程序。
與內部異常:
無法識別的元素的屏幕「。 (線 1)(第1行)CustomConfigurationSection的
定義:
public class CustomConfigurationSection: ConfigurationSection
{
public CustomConfigurationSection()
{
}
}
配置是一個自定義的類,它有一個屬性名爲部分,即具有類型 'ConfigurationSectionCollection' 的一個實例。
而且在sectionXml傳入的XML是:
<monitor>
<screens>
<screen>
<regions>
<region>
<labelCoordinates />
<startupApplication>Internet</startupApplication>
<color />
<width>426</width>
<height>266</height>
<x1>0</x1>
<x2>0</x2>
<y1>0</y1>
<y2>0</y2>
</region>
</regions>
<height>800</height>
<width>1280</width>
</screen>
<screen>
<regions />
<height>0</height>
<width>0</width>
</screen>
</screens>
</monitor>
我怎樣才能得到這個工作?
請發佈您的完整CustomConfigurationSection類和任何支持類。 – 2009-12-31 18:33:04