??? ??? ????? ????????? ??????? ?????????? ?? ??? ????? ????? ???????? Visual Basic .NET ?? Visual Basic 2005

?????? ????????? ?????? ?????????
???? ???????: 313405 - ??? ???????? ???? ????? ????? ??? ???????.
?????? ??? ????? Microsoft C# Visual Microsoft .NET ?? ??? ???????? ???? 815786.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ????? ????? ????????? ??????? ?? ??? ????? (.config) ????? ????????? ???? ??? ????? ??? ??????? ?????? ??????? ??????? ??. ???? ???? ????? ????? ??? ????? ???????? ???????? ?? ??? ???????.


???????

???? ??????? ??????? ??????? ?????? ??? ????? ?????? ???????? ?????? ? ??? ??????? ???? ???????:
  • ???? ??????? Microsoft Windows 2000 ?? Microsoft Windows XP ?? Microsoft Windows Server 2003
  • Microsoft Visual Studio .NET (2002) ?? Microsoft Visual Studio .NET (2003) ?? Microsoft Visual Studio 2005
????? ??? ??????? ??? ??????? ??? ???????? ???????:
  • ??? ??????? ??????? (XML)
  • ????? ??????? .NET

????? ????? ???? ?????? ???? ?????? ????? ??? ?????

????? ????? ??????? ??????? ???? ??? ??????? ???????? ?? ???????. ??? ??? ????? ??????? ?? XML ?????. ????? System.Configuration ?????? ??????? System.Collections.Specialized ?? Microsoft .NET Framework ???? ???????? ???????? ??????? ?? ??? ????? ????? .NET ????? ??? ???????.

?????? ????? ???? ???? ?????? ??????? ??? ??????? ???????? ????? ??? ??????? ? ???? ??????? ???????:
  1. ??? ????? Visual Studio .NET ?? Visual Studio 2005.
  2. ????? ????? "????? ???? ????" ???? ???? ConConfig ?? Visual Basic .NET ?? 2005 Visual Basic. Visual Basic .NET ?? Visual Basic 2005 ?????? ?????? ????? ???? ?????? ??????? 1 ???? ???????.
  3. ???? ??? ?????? ?????? ??? ConConfig ?? Project ?????? ? ??? ??? ????? ? ?? ???? ??? ????? ???? ????.

    ?????? ?? Visual Studio 2005 ? ???? ??? ?????? ?????? ??? ConConfig ?? Project ??????? ???? ??? ????? ??? ?? ???? ??? ???? ????.
  4. ?? ???? ?????? ????? ???? ???? ? ??? ???? ??? ????? ??????? ???? ??? ??? ?? ?? ?????? ????? App.config ??? ???????.

    ??????Visual Studio .NET ?? IDE 2005 Visual Studio ???? App.Config ??? ?????? ??? ???? ????? ?????? ??????? ??? ??????? ??????? ?? ????? ????? ?? <ApplicationName>. <Application Type>.config ?????.
  5. ????? ??????? ??? ????? ????? ?????? ??????? ??????? ?????? ???? ??? ?????? ?? ????? ?????/????. ????? ????? <add> ????? ?? <appsettings> ?????? ???? ??????? ????????. ????? ?? ??? ???? ??????? ??? ??? <add> ??????. <add> ?????? ?? ??????? ??????:
    <add key="theKey" value="theValue" />
    						
    ????? <appsettings> ?????? ?? <add> ??????? ??? ??? ????? ??? ???????? <configuration>?</configuration>. ??? ???? ??????? ????? ??? ??????? ???????<appsettings> ?????? ????? ????? ?????/???? ?????:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    	<appSettings>
    		<add key="Key0" value="0" />
    		<add key="Key1" value="1" />
    		<add key="Key2" value="2" />
    	</appSettings>
    </configuration>
    					
  6. ?? "?????? ??????" ???? ????? ??????? ??? Module1.vb ???? ???? ????????? ???????? ?????? ??????? 1. ?? ?????? ???????? ??????? ??? ?????? ??????? ????????? ???????? ?????? ??:

    ?????? ??? ?? ???? ??? ???????? ??? ??? ?????? ???? ?? ???.
    Imports System.Configuration
    Imports System.Collections.Specialized
    					
  7. ?? ??????? ??????? Sub ????? ????? ????? ???????? ?????? ?? ????? ??? ????? ?? <appsettings> ????? ?? ??? ???????:
    Dim sAttr As String
    					
  8. ??????? ???? ????? ???? ?? <appsettings> ?????? ?? ??? ??????? ??????? ????? AppSettings ??? ConfigurationSettings. ????? ??? ConfigurationSettings ?? ????? ????? System.Configuration. ????? ????? ????? AppSettings ????? ????? ????? ???? ????? ??? ????? ? ????? ??????? ?????? ???????? ???????.

    ??????? ???????? ???????? ??????? ?????? ????? Key0 ?? ??? ??????? ????????. ???????? ???????? ?? ??? ??? ?????? ?? ????? ????? sAttr. ?? ???? ??? ???? ????? ???? ?????? Nothing ????? ?? sAttr. sAttr
    sAttr = ConfigurationSettings. AppSettings("Key0")
    					
  9. ???? ???? ???? ???????? ??????? ?? ???? ???? ?????? ?????? Console.WriteLine:
    Console.WriteLine("The value of Key0: " & sAttr)
    					
  10. ????? ??????? ???? ???? ??? ????? AppSettings ???????? ???? ????? ?????/???? ?? <appsettings> ??????. ??? ?? ???? ??? ?????? ??? ??????? ??????? AppSettings ??????? ?????? ???? ????? ?????/???? ????????. ??? ????? ??? ??????? ?? ??? NameValueCollection ???? ????? ??? ??????? ?????/???? ??? ????? ????? ???????. ??? NameValueCollection ?????? ?? ????? ????? System.Collections.Specialized.
    Dim sAll As NameValueCollection
    sAll = ConfigurationSettings.AppSettings()
    					
  11. ???? ??????? AllKeys ?? NameValueCollection ???? ????? ??? ????? ??? ????? ????? ???????. ?????? ???? ??????? ?????? ????? ???? ?????? AllKeys ?????? ??? ?? ????? ???? ???????? ???????. ?? ????? ????? ?? AllKeys ?? ????? ?????? ???.
    Dim s As String
    For Each s In sAll.AllKeys
    					
  12. ???? ?????? ?? ?? ??????? Console.WriteLine ???? ??????? ??????? ???????? ?? ???? ?????? ????. ??????? ?????? ???? ????? ??????? ??? "s". ?????? ??? ???? ?? sAllNameValueCollection ?????? ??? ?????? ???????? ?????? ??.

    ??? ???? ??????? ??? ??? ??????? ????? ????? Key0 ? ????? sAll("Key0") ?????? ???????? ?????? ??. ????? ??????? Console.Readline ???? ??????. ????? ??? ENTER ?????? ???????.
        Console.WriteLine("Key: " & s & " Value: " & sAll(s))
    Next
    Console.Readline
    					

???? ?? ???? ?? ???

???? ??????? F5 ?????? ????????? ????????. ??? ??? ???? ???? ?????? ????? ?????/???? ?? <appsettings> ??? ???? ??????? ???????? ??? ???:
The value of Key0: 0
Key: Key0 Value:0
Key: Key1 Value:1
Key: Key2 Value:2
					

????? ??? ????????? ????????

Imports System.Configuration
Imports System.Collections.Specialized

Module Module1

    Sub Main()
        Dim sAttr As String

        sAttr = ConfigurationSettings.AppSettings("Key0")
        Console.WriteLine("The value of Key0: " & sAttr)
        
        Dim sAll As NameValueCollection
        sAll = ConfigurationSettings.AppSettings()

        Dim s As String
        For Each s In sAll.AllKeys
            Console.WriteLine("Key: " & s & " Value: " & sAll(s))
        Next
		  Console.ReadLine()
    End Sub

End Module
				

????? ????? (ConConfig.exe.config) ??? ?????

<configuration>
	<appSettings>
		<add key="Key0" value="0"/>
		<add key="Key1" value="1"/>
		<add key="Key2" value="2"/>
	</appSettings>
</configuration>
				

??????? ??????? ????????

  • ??? ??? ??? ????? ?????? XML. ???? ?? ????? ???? ????? ???? ???? XML. ???? ?? XML ???? ????? ??????. ??? ?? ??? ????? XML ????? ??? ?? ??? ????? ?? ????? ???? ???? ??????? System.Configuration.Configuration.

    ??? ???? ??????? ??? ??? ?????? ??? ??????? <add> ?????? ?? ?????? ????? "?" ????? ?? ???? ????? "? ?" ?? ??? ??? <appsettings> ???? ?????? <appsettings> (?? ????? ???? "A" ????? ?? ????? "a") ? ???? ????? ???.
  • ??? ????? ??? ??????? ?? ???????.
  • ??? ??????? ???? ?????? ?????? ???? ??? ??????? ????? ??? ????? ????? ???? ???? Visual Studio ??? ??? ?? ?????? ?? ??? ?????? ??? ??????? ??????? ??:
    ApplicationName. .config ApplicationType
    ??? ???? ApplicationName ?? ??? ??????? ApplicationType ?? ??? ??????? (??? ???? ??????? exe) ??? .config ????? ????????.

?????

????? ?? ?????????? ?? ?????? ????? MSDN ???????? ??? ?????:
????? ConfigurationSettings.AppSettings
http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsettings.appsettings(vs.71).aspx
????? ????? System.Configuration
http://msdn2.microsoft.com/en-us/library/system.configuration(vs.71).aspx

???????

???? ???????: 313405 - ????? ??? ??????: 15/?? ??????/1427 - ??????: 5.5
????? ???
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
????? ??????: 
kbmt kbvs2005swept kbvs2005applies kbconfig kbhowtomaster KB313405 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????313405

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com