Archives / 2010 / March
  • Using custom .net classes in ASP Classic Compiler

    To use custom .net classes, I extended VBScript syntax with the Imports statement. The Imports statement introduce the top namespace to the VBScript, as in the example below. The following example demonstrates using ADO.NET in ASP Classic Compiler:

        imports system
        dim filePath = Server.MapPath("/Database/authors.mdb")
        dim oleConn = new"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath)

        dim cmd = new"SELECT * From authors", oleConn)
        dim dr = cmd.ExecuteReader()
        do while dr.Read()
            response.Write(dr.GetString(1) & "<br/>")

    In the example above, “imports system” instructs that system is a namespace rather than an object. When encounters, it follows the namespace hierarchy to find the oledbconnection class.

    However, does not automatically search all the loaded assemblies. Instead, it only searches the assemblies it was instructed search. will always search the system.dll assembly. However, to instruct to also search in the, we need to add the following code to global.asax.cs:

    using System.Reflection;
    using Dlrsoft.Asp;

    protected void Application_Start(object sender, EventArgs e)
        Assembly a1 = Assembly.Load("System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089");

    The above code tells AspHandler to search the System.Data.dll assembly for classes.

    Lastly, to saves the typing of the fully qualified class name, the “imports” statement also supports alias. The following code demonstrates using alias to save typing:

    imports t = system.text

    dim sb = new t.StringBuilder()
    sb.append(" is ")
    sb.append(" stringbuilder!")
    response.write sb.toString()


  • Uploaded ASP Classic Compiler Build

    It has been a long time without a new release. This release contains only a few small fixes, but it is a change in the strategy. I decided to branch the code: one branch to stabilize the VBScript 4.0 features and the other branch to implement the VBScript 5.0 features such as Eval/Execute and VBScript classes.

    The reason is that not all users need VBScript 5.0 features. Some users have only a small number of VBScript classes and can easily convert them to C# classes as can use .net classes. Although I still have a lot to do to reach a mature release, some users only use limited VBScript features so they can use ASP Classic Compiler first. I will issue a license under the “Early Access Program” for those users who want to go live with pre-release versions of ASP Classic Compiler.

    The “Early Access Program” is an enterprise/ISV class of program with source code access. It allows participating users to self-support under emergency situations with source code access. Although the compiler code may have a steep learning curve, many users can learn simple bug fixes fairly quickly by following bug fixes in the source control system. The remaining users can still get the binaries from the Codeplext site without warranty. If you are interested in the program, please contact me using the contact user form.