18.3.2.Testing the Virtuoso Mono Runtime Environment

To test that you have successfully started the Virtuoso server with Mono CLR runtime support make a simple library, import the contained class into Virtuoso and call it.

Using an text editor create a C# source file in the server root directory called sanity.cs, with the following contents:

using System;

public class sanity
{
    public static string test(string  name) {
       return "Hello "+ name + ", from Virtuoso";
    }
}

This sample needs to be compiled into bytecode assembly before it can be used. Make sure you environment is configured to use Mono, change directory to the Virtuoso server root containing the C# source file. Run:

bash$ mcs /target:library sanity.cs
Compilation succeeded

Now this library must be introduce to the Virtuoso Server. Using ISQL use the following commands to test the CLR:

C:\Program Files\OpenLink\Virtuoso 3.0\bin>isql 1112
Connected to OpenLink Virtuoso
Driver: 03.00.2315 OpenLink Virtuoso ODBC Driver
OpenLink Interactive SQL (Virtuoso), version 0.9849b.
Type HELP; for help and EXIT; to exit.
SQL> DB..import_clr (vector ('sanity'), vector ('sanity'));

Done. -- 300 msec.
SQL> select sanity::test('Rob');
callret
VARCHAR
______________________________________________

Hello Rob, from Virtuoso

1 Rows. -- 60 msec.

Congratulations, you have proven that your Virtuoso server can run .NET classes via Mono Runtime.

[Tip] See Also:

The Virtuoso Tutorials, which are installed with the Demo Virtuoso Server (port 1112), contains numerous samples further demonstrating the use of the CLR, .NET, Mono and Virtuoso.

[Tip] See Also:

The Create Assembly Syntax

The External Hosted Create PROCEDURE Syntax