Compile .Net code on the fly - VB.Net

Released 7 years ago , Last update 7 years ago

Compile and execute .NET code on the fly

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!

Pricing

14 day 14-day money-back guarantee

$29.99

Personal License

  • Perpetual license

  • 1 site, unlimited servers

  • No distribution (hosted use only)

  • Commercial use

Installation and usage

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#")
2 licenses, starting from From » $29.99 View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


Or enter your name and Email
  • M Mary 6 years ago
    I want to compile code that a user enters into a textbox. The code will contain functions that I provide the user with. Will I be able to use the custom compiler class to compile the code in vb?