Accessing COM Objects via C# tutorial
Accessing COM Objects via C# Using the .NET to access native COM objects from Virtuoso/PL

## Overview

The following tutorial demonstrates how Virtuoso can access MS Windows COM objects via .NET.

The demonstrations in this section highlight transparent integration (hosting) between Virtuoso, the Microsoft .NET implementations of the ECMA Common Language Infrastructure (CLI) and the Win32 COM Layer.

## Prerequisites

The following prerequisites ensure the usability of these tutorial demos on Windows:

- .NET Runtime and Frameworks
- .Net Runtime and Framework SDK (if you seek to write your own Objects for integration with Virtuoso)
- Virtuoso Universal Server for Windows with .NET CLR Hosting

## Tutorial Example

The following tutorial shows how the Virtuoso server can call native Win32 COM objects using the .NET runtime as intermediary.

Please follow the steps below to maximize the value of this tutorial:

1. Register the COM library COM/VirtCOMServer/Debug/VirtCOMServer.dll with COM (via regsvr32.exe COM/VirtCOMServer/Debug/VirtCOMServer.dll).
2. Copy the interop assembly COM/VirtCOMServer/VirtCOMServer.dll next to the virtuoso server binary (if not allready there).
3. Click on the "Set Initial State" link which registers the C# interop class for the Interface IVirtCOMObject with Virtuoso. Click on the "ho_s_15.sql" link to see the code behind this step
4. Click on the "Run" links to actually experience the demo

Demo Breakdown

1. "ho_s_15.sql" registers the "VirtCOMServer.CVirtCOMObjectClass" C# interop class with Virtuoso. Click on the "VirtCOMObject.c" and "VirtCOMObject.h" link to see the C++ source code of this interface and it's class
2. "vsp1.vsp" uses the methods "AddAmount", "Clear" and "get_balance" of the "VirtCOMServer.IVirtCOMObject" Interface to sum a number of amounts and get the resulting total.