Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Loading app.config from a remote location fails to load section handler.

Loading app.config from a remote location fails to load section handler.

Scheduled Pinned Locked Moved C#
csharpcomhelpquestionannouncement
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Larantz
    wrote on last edited by
    #1

    Hi guys. We're trying to implement a centralized configuration for all .net applications and by so we have created a master configuration at a specific location. We're then creating a custom configuration manager that uses both the local app.config and the centralized master configuration. The master configuration is read using System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(string path, UserLevel level). The appSettings section and all other custom sections are read and available but our problem occurs when we try to read the sections from the master configuration using ConfigurationManager.GetSection(string sectionName). We get a TypeLoadException no matter what type of section handlers we use - .NET handlers or custom handlers, and the method returns a System.Configuration.DefaultSection object instead of the intended type. Could not load type 'System.Configuration.NameValueSectionHandler' from assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Reading the same sections from the app.config of the exectuable produces no errors. Anybody with some ideas as to what causes the problem? -Larantz

    for those about to code, we salute you
    Please refer to the Forum Guidelines for appropriate posting.

    L 1 Reply Last reply
    0
    • L Larantz

      Hi guys. We're trying to implement a centralized configuration for all .net applications and by so we have created a master configuration at a specific location. We're then creating a custom configuration manager that uses both the local app.config and the centralized master configuration. The master configuration is read using System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(string path, UserLevel level). The appSettings section and all other custom sections are read and available but our problem occurs when we try to read the sections from the master configuration using ConfigurationManager.GetSection(string sectionName). We get a TypeLoadException no matter what type of section handlers we use - .NET handlers or custom handlers, and the method returns a System.Configuration.DefaultSection object instead of the intended type. Could not load type 'System.Configuration.NameValueSectionHandler' from assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Reading the same sections from the app.config of the exectuable produces no errors. Anybody with some ideas as to what causes the problem? -Larantz

      for those about to code, we salute you
      Please refer to the Forum Guidelines for appropriate posting.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The type System.Configuration.NameValueSectionHandler is in the System.Configuration namespace but it is actually defined in System.dll and not System.Configuration.dll as you might assume, so change your configuration section to <section name="" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> and it should work.

      L 2 Replies Last reply
      0
      • L Lost User

        The type System.Configuration.NameValueSectionHandler is in the System.Configuration namespace but it is actually defined in System.dll and not System.Configuration.dll as you might assume, so change your configuration section to <section name="" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> and it should work.

        L Offline
        L Offline
        Larantz
        wrote on last edited by
        #3

        I'll try that. Thanks for the tip. :) -Larantz

        for those about to code, we salute you
        Please refer to the Forum Guidelines for appropriate posting.

        1 Reply Last reply
        0
        • L Lost User

          The type System.Configuration.NameValueSectionHandler is in the System.Configuration namespace but it is actually defined in System.dll and not System.Configuration.dll as you might assume, so change your configuration section to <section name="" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> and it should work.

          L Offline
          L Offline
          Larantz
          wrote on last edited by
          #4

          It seems that the section handler did load so the TypeLoadException is gone. But instead of actually returning a NameValueCollection - it still just returns a System.Configuration.DefaultSection which is useless. I just can't get my head around why this is occurring. It's the same for custom section handlers. -Larantz

          for those about to code, we salute you
          Please refer to the Forum Guidelines for appropriate posting.

          L 1 Reply Last reply
          0
          • L Larantz

            It seems that the section handler did load so the TypeLoadException is gone. But instead of actually returning a NameValueCollection - it still just returns a System.Configuration.DefaultSection which is useless. I just can't get my head around why this is occurring. It's the same for custom section handlers. -Larantz

            for those about to code, we salute you
            Please refer to the Forum Guidelines for appropriate posting.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            You might find this useful http://www.eggheadcafe.com/software/aspnet/30832856/backwards-compatibility-o.aspx[^]

            L 1 Reply Last reply
            0
            • L Lost User

              You might find this useful http://www.eggheadcafe.com/software/aspnet/30832856/backwards-compatibility-o.aspx[^]

              L Offline
              L Offline
              Larantz
              wrote on last edited by
              #6

              Well that sure answers it. I'll have a look at the document mentioned there. Thanks mate! -Larantz

              for those about to code, we salute you
              Please refer to the Forum Guidelines for appropriate posting.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups