VBCodeProvider Constructor (IDictionary(String, String))
Collapse the table of content
Expand the table of content

VBCodeProvider Constructor (IDictionary<String, String>)

 

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

Namespace:   Microsoft.VisualBasic
Assembly:  System (in System.dll)

public VBCodeProvider(
	IDictionary<string, string> providerOptions
)

Parameters

providerOptions
Type: System.Collections.Generic.IDictionary<String, String>

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

Exception Condition
ArgumentNullException

providerOptions is null.

The value for providerOptions is obtained from the 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>

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

Imports System
Imports System.CodeDom.Compiler
Imports Microsoft.CSharp
Imports Microsoft.VisualBasic
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 'Main

    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 'DisplayVBCompilerInfo
End Class 'Program

LinkDemand

for full trust for the immediate caller. This member cannot be used by partially trusted code.

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft