18.2.2. Testing the Virtuoso .NET Runtime Environment
To test that you have successfully started the Virtuoso server with .NET 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. Use a command prompt that is suitable set up to find .NET utilities in its path, the .NET Framework SDK installation provides a shortcut in the Start menu to a command prompt that is preconfigured. From the command prompt change directory to the Virtuoso server root containing the C# source file.
C:\Program Files\OpenLink\Virtuoso 3.0\bin>csc /target:library sanity.cs Microsoft (R) Visual C# .NET Compiler version 7.00.9466 for Microsoft (R) .NET Framework version 1.0.3705 Copyright (C) Microsoft Corporation 2001. All rights reserved.
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.
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 and Virtuoso. |
See Also: | |
---|---|
The Create Assembly Syntax The External Hosted Create PROCEDURE Syntax |