Full refund within 14 days of purchase date.
The CustomCompiler class in this component will compile and execute any .NET code passed to it as a string.
Simply add the CustomCompiler class to any existing project for compile-on-the-fly functionality!
To install the CustomCompiler class drop the CustomCompiler.vb class into an existing project.
It's very easy to use the CustomCompiler class. There are a number of code samples enclosed in the component's zip file. Simply create a new instance of the CustomCompiler class, and call its ExecuteCode() method.
For example:
'Create a new instance of the custom compiler class
Dim myCustomCompiler As New CustomCompiler()
'An example of a full class to be compiled and executed
Dim AppCode1 =
Imports System
Class MyTestClass
Public Sub MyMethod()
Console.WriteLine("This line of VB.Net was executed dynamically.")
End Sub
End Class
myCustomCompiler.ExecuteCode(AppCode1, "MyTestClass.MyMethod", CustomCompiler.CodeScope.FullClassProvided, "VisualBasic")
'An example of a full class to be compiled and executed in C#
Dim AppCode2 =
using System;
class someTestClass {
public void myMethod() {
Console.WriteLine("This line of C# was executed dynamically.");
}
}
myCustomCompiler.ExecuteCode(AppCode2, "someTestClass.myMethod", CustomCompiler.CodeScope.FullClassProvided, "C#")
'An example of a snippet of code to be compiled and executed
Dim SnippetCode1 =
Dim x As Integer = 5
Dim y As Integer = 6
Dim z As Integer = x + y
Console.WriteLine("{0} + {1} = {2}", x, y, z)
myCustomCompiler.ExecuteCode(SnippetCode1, Nothing, CustomCompiler.CodeScope.SnippetOnlyStatements, "VisualBasic")
'Another example of a snippet of code to be compiled and executed
Dim SnippetCode2 =
Const val1 = 9
Dim val2 As Integer = System.Math.Sqrt(val1)
My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Desktop & "\testfile.txt", val2, True)
Console.WriteLine("Value has been written to text file")
myCustomCompiler.ExecuteCode(SnippetCode2, Nothing, CustomCompiler.CodeScope.SnippetOnlyStatements, "VisualBasic")
'An example of a snippet of code that includes methods, to be compiled and executed
Dim BiggerSnippetCode =
private int GetMyValue() {
int x = 5;
int y = 6;
int z = x + y;
return z;
}
public void ExecuteMe() {
Console.WriteLine("Some value = {0}", GetMyValue());
}
myCustomCompiler.ExecuteCode(BiggerSnippetCode, "ExecuteMe", CustomCompiler.CodeScope.SnippetWithMethods, "C#")
Questions & Comments