ProviderSettings Class

Note: This class is new in the .NET Framework version 2.0.

Represents a group of configuration elements that configure a provider.

Namespace: System.Configuration
Assembly: System.Configuration (in system.configuration.dll)

'Declaration
Public NotInheritable Class ProviderSettings
	Inherits ConfigurationElement
'Usage
Dim instance As ProviderSettings

public final class ProviderSettings extends ConfigurationElement
public final class ProviderSettings extends ConfigurationElement

ASP.NET uses providers to perform specific services required by a feature. For example, the membership feature uses a provider to coordinate the persistence of membership data in a database.

In a configuration file, individual providers are added to a providers element within a particular feature section.

The ProviderSettings class represents a particular group of settings that are added to the providers element within a configuration section. Typically the configuration attributes specified by the add directive include a name, type, and other properties.

The following code example shows how to use the ProviderSettings.

Imports System
Imports System.Collections
Imports System.Collections.Specialized
Imports System.Text
Imports System.Configuration


' Show how to use a custom protected configuration
' provider.

Public Class UsingProviderSettings
   
   
   
   Private Shared Sub GetProviderSettings()
      ' Get the application configuration file.
        Dim config _
        As System.Configuration.Configuration = _
        ConfigurationManager.OpenExeConfiguration( _
        ConfigurationUserLevel.None)
      
        Dim pSection As _
        ProtectedConfigurationSection = _
        config.GetSection("protectedData")
      
        Dim providerSettings _
        As ProviderSettingsCollection = _
        pSection.Providers
      
      Dim pSettings As ProviderSettings
      For Each pSettings In  providerSettings
         
            Console.WriteLine( _
            "Provider settings name: {0", _
            pSettings.Name)
         

            Console.WriteLine( _
            "Provider settings type: {0", _
            pSettings.Type)

            Dim parameters _
            As NameValueCollection = pSettings.Parameters
         
            Dim pEnum _
            As IEnumerator = parameters.GetEnumerator()
         
         Dim i As Integer = 0
         While pEnum.MoveNext()
                Dim pLength As String = _
                parameters(i).Length.ToString()
                Console.WriteLine( _
                "Provider ssettings: {0 has {1 parameters", _
                pSettings.Name, pLength)
         End While
        Next pSettings

   End Sub 'GetProviderSettings
      
   
    Public Shared Sub Main(ByVal args() As String)

        GetProviderSettings()
    End Sub 'Main 
End Class 'UsingProviderSettings

The following is an excerpt of the configuration file used by the above example.

  <configProtectedData>
    <providers>
      <clear />
        <add keyContainerName="pcKey.txt" 
          name="TripleDESProtectedConfigurationProvider"
type="Samples.Aspnet.Configuration.TripleDESProtectedConfigurationProvider, protectedconfigurationproviderlib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=79e01ae0f5cfc66f, processorArchitecture=MSIL" />
    </providers>


  </configProtectedData>

  <connectionStrings>
    <add name="NorthwindConnectionString" 
      connectionString="Data Source=webnetue2;Initial Catalog=Northwind;User ID=aspnet_test;Password=test"
providerName="System.Data.SqlClient" />
  </connectionStrings>

</configuration>

System.Object
   System.Configuration.ConfigurationElement
    System.Configuration.ProviderSettings

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show: