public class VisualBasicCompiler : Compiler
Public Class VisualBasicCompiler
Inherits Compiler
Dim instance As VisualBasicCompiler
public ref class VisualBasicCompiler : public Compiler
type VisualBasicCompiler =
class
inherit Compiler
end
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
Public NotInheritable Class Form1 : Inherits Form
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' The VisualBasic.NET compiler instance.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Dim WithEvents vbCompiler As Compiler =
New VisualBasicCompiler(CompilerVersions.V4)
Private Sub Form1_Shown() Handles MyBase.Shown
With Me.vbCompiler.Compilersettings
.GenerateDebugInformation = True
.GenerateWarnings = True
.GenerateXmlDocumentation = True
.HighEntropyEnabled = True
.IntegerOverflowChecksEnabled = False
.OptimizationsEnabled = True
.Platform = Platform.AnyCpu
.SubsystemVersion = SubsystemVersions.WindowsXP
.TreatWarningsAsErrors = False
.Verbose = True
.VerboseSyntax = False
.WarningLevel = WarningLevelEnum.Level3
.LibraryPaths.Add(IO.Directory.GetCurrentDirectory)
End With
Dim referencedAssemblies As New List(Of String)
referencedAssemblies.AddRange({"System.dll", "System.Windows.Forms.dll"})
' Compile a VB Console App from string.
vbCompiler.CompileFromString(netAssembly:=NetAssembly.Console,
targetFile:="C:\VB Default Console App.exe",
sourceCode:=Templates.TemplateVbConsoleApp,
mainClass:="MainNamespace.MainModule",
referencedAssemblies:=referencedAssemblies,
resources:=Nothing,
iconFile:=Nothing)
' Compile a VB WinForms App from string.
vbCompiler.CompileFromString(netAssembly:=NetAssembly.WinExe,
targetFile:="C:\VB Default WinForms App.exe",
sourceCode:=Templates.TemplateVbWinFormsApp,
mainClass:="MainNamespace.MainClass",
referencedAssemblies:=referencedAssemblies,
resources:=Nothing,
iconFile:=Nothing)
' Compile a VB library from string.
vbCompiler.CompileFromString(netAssembly:=NetAssembly.DynamicLinkLibrary,
targetFile:="C:\VB Default Library.dll",
sourceCode:=Templates.TemplateVbLib,
mainClass:="MainNamespace.MainClass",
referencedAssemblies:=referencedAssemblies,
resources:=Nothing,
iconFile:=Nothing)
' Compile a VB local file that contains the sourcecode.
vbCompiler.CompileFromFile(netAssembly:=NetAssembly.WinExe,
targetFile:="C:\VB Custom App.exe",
sourceFile:="C:\SourceCode.vb",
mainClass:="MainNamespace.MainClass",
referencedAssemblies:=referencedAssemblies,
resources:=Nothing,
iconFile:=Nothing)
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Handles the <see cref="Compiler.CompilerWorkDone"/> event of the vbCompiler instance.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <param name="sender">
''' The source of the event.
''' </param>
'''
''' <param name="e">
''' The <see cref="CompilerWorkDoneEventArgs"/> instance containing the event data.
''' </param>
''' ----------------------------------------------------------------------------------------------------
Public Sub VbCompiler_CompilerWorkDone(ByVal sender As Object, ByVal e As Compiler.CompilerWorkDoneEventArgs) _
Handles vbCompiler.CompilerWorkDone
Console.WriteLine(String.Format("Compiler: {0}", e.CodeDomProvider.ToString()))
Console.WriteLine(String.Format("Parameters: {0}", e.CompilerParameters.CompilerOptions))
For Each war As CompilerWarning In e.CompilerWarnings
Console.WriteLine(String.Format("{0}| Warning: {1}", war.ErrorNumber, war.ErrorText))
Next war
For Each err As CompilerErrorEx In e.CompileErrors
Console.WriteLine(String.Format("{0}| Error: {1}", err.ErrorNumber, err.ErrorText))
Next err
If Not e.CompileErrors.Any Then
Console.WriteLine(String.Format("Compilation Successful: {0}", e.TargetFilePath))
End If
Console.WriteLine()
End Sub
End Class
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
VisualBasicCompiler | Initializes a new instance of the VisualBasicCompiler class. |
Compilersettings |
Gets or sets the settings of this Compiler.
(Inherited from Compiler) |
CompileFromFile |
Compiles a .NET assembly from the specified source code file.
(Inherited from Compiler) |
CompileFromString |
Compiles a .NET assembly from the specified source code string.
(Inherited from Compiler) |
Dispose |
Releases all the resources used by this instance.
(Inherited from Compiler) |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode | Serves as the default hash function. (Inherited from Object) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
CompilerWorkDone |
Occurs when the compiler finishes.
(Inherited from Compiler) |
CanConvertTo |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
CanConvertToT |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions) |
IsDisposable |
Determines whether the specified object is a disposable type
(i.e., it implements IDisposable interface).
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
ThrowIfNullTException |
Throws the specified exception if the source object is null.
(Defined by ObjectExtensions) |