0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.