VBCodeProvider Constructors

Definition

Initializes a new instance of the VBCodeProvider class.

Overloads

VBCodeProvider()

Initializes a new instance of the VBCodeProvider class.

VBCodeProvider(IDictionary<String,String>)

Initializes a new instance of the VBCodeProvider class by using the specified provider options.

VBCodeProvider()

Source:
VBCodeProvider.cs
Source:
VBCodeProvider.cs
Source:
VBCodeProvider.cs

Initializes a new instance of the VBCodeProvider class.

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

Applies to

VBCodeProvider(IDictionary<String,String>)

Source:
VBCodeProvider.cs
Source:
VBCodeProvider.cs
Source:
VBCodeProvider.cs

Initializes a new instance of the VBCodeProvider class by using the specified provider options.

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))

Parameters

providerOptions
IDictionary<String,String>

A IDictionary<TKey,TValue> object that contains the provider options.

Exceptions

providerOptions is null.

Examples

The following example shows how to specify the compiler version when creating a new instance of the VBCodeProvider class.

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

Remarks

In .NET Framework apps, you can obtain the value for providerOptions from the <providerOptions> element in the configuration file. You can identify the version of the VBCodeProvider you want to use by specifying the <providerOption> element, supplying "CompilerVersion" as the option name, and supplying the version number (for example, "v3.5") as the option value. You must precede the version number with a lower case "v". The following configuration file example demonstrates how to specify that version 3.5 of the Visual Basic code provider should be used.

<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>  

See also

Applies to