Accessing COM Objects via C#
HO-S-15 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:
- Register the COM library COM/VirtCOMServer/Debug/VirtCOMServer.dll with COM (via regsvr32.exe COM/VirtCOMServer/Debug/VirtCOMServer.dll).
- Copy the interop assembly COM/VirtCOMServer/VirtCOMServer.dll next to the virtuoso server binary (if not allready there).
- 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
- Click on the "Run" links to actually experience the demo
Demo Breakdown
- "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
- "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.
In order to run this example you need Virtuoso Universal Server for Windows with .NET CLR Hosting.
| View the source | Action |
|---|---|
| 1. ho_s_15.sql | Set the initial state |
| 2. VirtCOMObject.cpp | |
| 3. VirtCOMObject.h | |
| 4. vsp1.vsp | Run |
OpenLink Home
Technical Support