VBCodeProvider Konstruktorer

Definition

Initierar en ny instans av VBCodeProvider klassen.

Överlagringar

Name Description
VBCodeProvider()

Initierar en ny instans av VBCodeProvider klassen.

VBCodeProvider(IDictionary<String,String>)

Initierar en ny instans av VBCodeProvider klassen med hjälp av de angivna provideralternativen.

VBCodeProvider()

Initierar en ny instans av VBCodeProvider klassen.

public:
 VBCodeProvider();
public VBCodeProvider();
Public Sub New ()

Gäller för

VBCodeProvider(IDictionary<String,String>)

Initierar en ny instans av VBCodeProvider klassen med hjälp av de angivna provideralternativen.

public:
 VBCodeProvider(System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ providerOptions);
public VBCodeProvider(System.Collections.Generic.IDictionary<string,string> providerOptions);
new Microsoft.VisualBasic.VBCodeProvider : System.Collections.Generic.IDictionary<string, string> -> Microsoft.VisualBasic.VBCodeProvider
Public Sub New (providerOptions As IDictionary(Of String, String))

Parametrar

providerOptions
IDictionary<String,String>

Ett IDictionary<TKey,TValue> objekt som innehåller provideralternativen.

Undantag

providerOptions är null.

Exempel

I följande exempel visas hur du anger kompilatorversionen när du skapar en ny instans av VBCodeProvider klassen.

Imports System.CodeDom.Compiler
Imports Microsoft.CSharp
Imports System.Collections.Generic



Class Program

    Shared Sub Main(ByVal args() As String)
        DisplayVBCompilerInfo()
        Console.WriteLine("Press Enter key to exit.")
        Console.ReadLine()

    End Sub

    Shared Sub DisplayVBCompilerInfo()
        Dim provOptions As New Dictionary(Of String, String)
        provOptions.Add("CompilerVersion", "v3.5")
        ' Get the provider for Microsoft.VisualBasic
        Dim vbProvider As VBCodeProvider = New VBCodeProvider(provOptions)

        ' Display the Visual Basic language provider information.
        Console.WriteLine("Visual Basic provider is {0}", vbProvider.ToString())
        Console.WriteLine("  Provider hash code:     {0}", vbProvider.GetHashCode().ToString())
        Console.WriteLine("  Default file extension: {0}", vbProvider.FileExtension)

        Console.WriteLine()

    End Sub
End Class

Kommentarer

I .NET Framework-appar kan du hämta värdet för providerOptions från elementet <providerOptions> i konfigurationsfilen. Du kan identifiera den version av som VBCodeProvider du vill använda genom att ange elementet <providerOption> , ange "CompilerVersion" som alternativnamn och ange versionsnumret (till exempel "v3.5") som alternativvärde. Du måste föregå versionsnumret med ett gemener "v". Följande konfigurationsfilexempel visar hur du anger att version 3.5 av Visual Basic kodprovider ska användas.

<configuration>
  <system.codedom>
    <compilers>
      <!-- zero or more compiler elements -->
      <compiler
          language="vb;VisualBasic"
          extension=".vb"
          type="Microsoft.VisualBasic.VBCodeProvider, System,
          Version=2.0.3600.0, Culture=neutral,
          PublicKeyToken=b77a5c561934e089"
          compilerOptions="/optimize"
          warningLevel="1" >
          <providerOption
            name="CompilerVersion"
            value="v3.5" />
        </compiler>
    </compilers>
  </system.codedom>
</configuration>

Se även

Gäller för