shibormot
shibormot

Reputation: 1638

Custom configuration section defined in executable

I have defined custom configuration section class in the same executable assembly (IVITerminal.exe) as this section for. In App.config I have:

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

But when I want to read section:

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

I got exception Could not load type 'IVITermital.Configuration.Section' from assembly 'IVITerminal'. of type System.Configuration.ConfigurationErrorsException.

Is it possible to define configuration sections in same exe?

Upvotes: 0

Views: 209

Answers (1)

brhardwick
brhardwick

Reputation: 3085

That error usually means that there was some sort of syntax error in your file. I.e. the placement was wrong, the spelling was incorrect, or an unclosed section.

Was there an inner exception?

The MSDN documentation describes the format as this:

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

More here: https://msdn.microsoft.com/en-us/library/2tw134k3.aspx

Upvotes: 1

Related Questions