2017-06-05 4 views
0

Ich habe benutzerdefinierte Konfiguration Abschnittsklasse in der gleichen ausführbaren Assembly (IVITerminal.exe) als dieser Abschnitt für definiert. In App.config ich habe:Benutzerdefinierte Konfigurationsabschnitt in ausführbaren definiert

<configSections> 
.... 
<section name="myconfig" type="IVITermital.Configuration.Section, IVITerminal"/> 
.... 
</configSections> 
.... 
<myconfig>....</myconfig> 

Aber wenn ich lesen Abschnitt will:

static void Main(string[] args) 
{ 
    var s = ConfigurationManager.GetSection("myconfig") as Section; 

Ich habe Ausnahme Could not load type 'IVITermital.Configuration.Section' from assembly 'IVITerminal'. vom Typ System.Configuration.ConfigurationErrorsException.

Ist es möglich, Konfigurationsabschnitte in derselben exe zu definieren?

Antwort

1

Dieser Fehler bedeutet normalerweise, dass in Ihrer Datei ein Syntaxfehler aufgetreten ist. I.e. Die Platzierung war falsch, die Schreibweise falsch oder ein nicht abgeschlossener Abschnitt.

Gab es eine innere Ausnahme?

Die MSDN-Dokumentation beschreibt das Format wie folgt aus:

<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> 

Mehr hier: https://msdn.microsoft.com/en-us/library/2tw134k3.aspx

+0

Sie danken es war ein Tippfehler in Klassennamen – shibormot

Verwandte Themen