2017-06-05 43 views
0

我在本節中爲相同的可執行程序集(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中定義配置節?

回答

1

該錯誤通常意味着文件中存在某種語法錯誤。即放置錯誤,拼寫錯誤或未封閉的部分。

是否存在內部異常?

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> 

這裏更多:https://msdn.microsoft.com/en-us/library/2tw134k3.aspx

+0

謝謝你這是在類名錯字 – shibormot

相關問題