app.config and and configurationelement

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

    #1

    app.config and and configurationelement

    Hi,

    I have the following app.config file:

    <configuratio n>
    <system.diagnos tics>

    ......

    </system.diagnost ics>

    <mysection name="myname">
    <role name="ana"></role>
    </mysection>
    </configuration>

    I would like to read the value for name ("ana").
    I created the following class:

    Public Class MyRole
    Inherits System.Configur ation.Configura tionElement
    Friend ElementName As String = "role"
    <System.Configu ration.Configur ationProperty(" name",
    isrequired:=Tru e)Public ReadOnly Property name() As String
    Get
    Return Ctype(Me("name" ),String)
    End Get
    End Property

    End Class


    When I use the class:

    Dim aRole as new myrole
    msgbox aRole.name

    shows an empty string.

    Please help.

    Thanks,

    Carly

Working...