Custom Configuration file Sections in 2.0

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Bysouth

    #1

    Custom Configuration file Sections in 2.0

    Hi

    I'm trying to create a series of config files for my Windows app (some of
    which may reside in arbitary locations unrelated to the exe file) and have
    been reading various examples using the System.Configur ation namespace.

    However, I just can't get anything to work using these examples e.g.
    http://msdn2.microsoft.com/en-us/library/2tw134k3.aspx - have adapted that
    one to work with a win app but get the error :

    An error occurred creating the configuration section handler for
    myCustomGroup/myCustomSection : Could not load type
    'MyConfigSectio nHandler.MyHand ler' from assembly
    'MyCustomConfig urationHandler, Version=1.0.0.0 , Culture=neutral ,
    PublicKeyToken= null'.

    All I want to do is to be able to read configuration info from an xml config
    file such as

    <myAppSetting s>
    <SectionA
    Setting1="12"
    Setting2="25"
    Setting3="anoth er value"
    />
    </myAppSettings>

    Can somebody point me in the right direction please?

    many thanks

    Richard Bysouth
    --
    -----------
    Please provide code examples in VB if possible...than ks!
    -----------
  • Yuan Ren[MSFT]

    #2
    RE: Custom Configuration file Sections in 2.0

    Hi Richard,

    Thanks for posting!

    For the current issue, the article is related about ASP.NET. If you want to
    get the information of element in your customer section, I recommend you
    use the ConfigurationMa nager class in the application. The article form
    MSDN gives us more explanation and some sample as below:
    http://msdn2.microsoft.com/en-us/lib...configurationm
    anager(VS.80).a spx

    I hope this will be helpful. If you have any issues or concerns, please let
    me know. It's my pleasure to be of assistance.

    Regards,

    Yuan Ren [MSFT]
    Microsoft Online Support
    =============== =============== =============== =========
    PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were
    updated on February 14, 2006. Please complete a re-registration process
    by entering the secure code mmpng06 when prompted. Once you have
    entered the secure code mmpng06, you will be able to update your profile
    and access the partner newsgroups.
    =============== =============== =============== =========
    When responding to posts, please "Reply to Group" via your newsreader
    so that others may learn and benefit from this issue.
    =============== =============== =============== =========
    This posting is provided "AS IS" with no warranties, and confers no rights.
    =============== =============== =============== =========

    Comment

    • Richard Bysouth

      #3
      RE: Custom Configuration file Sections in 2.0

      Yuan

      Thanks but I had already read this section of the documentation. What I
      don't seem to be able to do with the ConfigurationMa nager class is to open a
      config file in a location other than the same folder as the exe file.
      It only has the OpenExeConfigur ation and OpenMachineConf iguration methods,
      nothing like "OpenConfigurat ion"?

      For example, I would like to be able to do something like:

      Dim config As System.Configur ation.Configura tion = _
      ConfigurationMa nager.OpenConfi guration("c:\te st\myconfig.con fig")

      Dim sectionA As SectionA = _
      config.Sections ("SectionA")

      messagebox.show (sectionA.Setti ng1)
      ---
      myconfig.config would look something like this:

      <myAppSetting s>
      <SectionA
      Setting1="12"
      Setting2="25"
      Setting3="anoth er value"
      />
      </myAppSettings>

      Or am I better off just writing my own code to read the file settings using
      XmlReader or similar?

      Richard
      --
      -----------
      Please provide code examples in VB if possible...than ks!
      -----------


      ""Yuan Ren[MSFT]"" wrote:
      [color=blue]
      > Hi Richard,
      >
      > Thanks for posting!
      >
      > For the current issue, the article is related about ASP.NET. If you want to
      > get the information of element in your customer section, I recommend you
      > use the ConfigurationMa nager class in the application. The article form
      > MSDN gives us more explanation and some sample as below:
      > http://msdn2.microsoft.com/en-us/lib...configurationm
      > anager(VS.80).a spx
      >
      > I hope this will be helpful. If you have any issues or concerns, please let
      > me know. It's my pleasure to be of assistance.
      >
      > Regards,
      >
      > Yuan Ren [MSFT]
      > Microsoft Online Support
      > =============== =============== =============== =========
      > PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were
      > updated on February 14, 2006. Please complete a re-registration process
      > by entering the secure code mmpng06 when prompted. Once you have
      > entered the secure code mmpng06, you will be able to update your profile
      > and access the partner newsgroups.
      > =============== =============== =============== =========
      > When responding to posts, please "Reply to Group" via your newsreader
      > so that others may learn and benefit from this issue.
      > =============== =============== =============== =========
      > This posting is provided "AS IS" with no warranties, and confers no rights.
      > =============== =============== =============== =========
      >
      >[/color]

      Comment

      • Yuan Ren[MSFT]

        #4
        RE: Custom Configuration file Sections in 2.0

        Hi Richard,

        Thanks for your reply!

        As your description, actually the ConfigurationMa nager class is designed
        for the specific config file. If you want to read your own config file, the
        XmlReader class is appropriate at the current stage. The following document
        from MSDN2 demonstrates how to read the attributes from XML document:
        http://msdn2.microsoft.com/en-us/lib...7w(VS.80).aspx

        Hope this will be helpful!

        Regards,

        Yuan Ren [MSFT]
        Microsoft Online Support
        =============== =============== =============== =========
        PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were
        updated on February 14, 2006. Please complete a re-registration process
        by entering the secure code mmpng06 when prompted. Once you have
        entered the secure code mmpng06, you will be able to update your profile
        and access the partner newsgroups.
        =============== =============== =============== =========
        When responding to posts, please "Reply to Group" via your newsreader
        so that others may learn and benefit from this issue.
        =============== =============== =============== =========
        This posting is provided "AS IS" with no warranties, and confers no rights.
        =============== =============== =============== =========

        Comment

        Working...