Link to home
Start Free TrialLog in
Avatar of skdan
skdanFlag for Slovakia

asked on

VB 2010 - Create Custom Configuration Section Using ConfigurationSection

Hi,

I am trying to create custom section in app.connfig file of my Windows Form application following instructions on this page:

http://msdn.microsoft.com/en-us/library/2tw134k3.aspx

but don't know how to do it.

I would like to have this in final:

<configuration>
   <startup>
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
   </startup>
   <productIdGroup>
      <ProductID="AAAAA-BBBBB"/>
   </productIdGroup>
</configuration>

Open in new window


Until now I have this code:

Imports System.Configuration

Namespace TestSection
    Class CustomConfigSection
        Inherits ConfigurationSection

        ' Create a "productId" element.
        <ConfigurationProperty("productId")> _
        Public Property ProductID() As String
            Get
                Return Me("productId")
            End Get
            Set(ByVal value As String)
                Me("productId") = value
            End Set
        End Property
    End Class
End Namespace

Open in new window


How can I store a value to key "ProductID" and save to app.config file?

I know, there are other possibilities how to store user settings, but I would like to store it in my custom section.

Thanks.
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Avatar of skdan

ASKER

Yes, but I would like to create section, which is not a part of Users Settings section.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of skdan

ASKER

I will study this tutorial. I think, this is exactly what I need. Thank you very much.