I’ve been able to get this working using the Unmanaged Exports – which is HUGE for folks who need to create DLL’s and want to take advantage of .NET and the whole C# ecosystem.
This avoids the whole COM-Visible and COM-interop nightmare which can slow down a project, and also complicate things.
“Unmanaged Exports” a C# class library package by Robert Giesecke.
No more ActiveX wrapper! Excellent stuff!
Here’s what you do:
- Get the NuGet packages for VS 2010 or better, install them in your VS 2012 system.
- Create a VS C# Class Library Project
- When you create a method make sure its “static”, and that you decorate it with [DllExport]
- Compile the project, place the DLL in the runtime location of your Xojo project or make sure the Declare has a direct path
to that DLL - Voila! .NET DLL access from Xojo… no ActiveX wrapper, no COM-Interop.
Below is a code snippet.
C#
using System;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;
public class TestExport
{
[DllExport]
public static int Test(string TestString)
{
return TestString;
}
}
Declare Function Test lib "TestExport.dll" (msg as CString) AS String
Msg ( Test ("Hello, .NET Class Library DLL!"))