How can I include a C# DLL in XOJO? I tried the following, but did not work.
Declare Function AddTwo Lib "Test.dll" (a as Integer, b as Integer) As Integer
res = AddTwo(2,3)
Test.dll C# Code :
public class Test_Class
public static int AddTwo(int a, int b)
return a + b;
There are 2 kinds of code, managed (as C#, depends largely on its runtime) and unmanaged (as Rust, C, and C++). Xojo can only use and link to unmanaged code with “C like interfaces”. You could try to experiment C# unmanaged wrappers/exporters as said here:
I have had some success with the upgraded versions of UnmanagedExports.
Or write your DLL in Rust or C directly.
For my AddTwo example, please follow the instructions at my website at:
There is example code that can be downloaded with my Github account at:
GitHub - eugenedakin/CSharpDLLXojo: Build a DLL in CSharp with External Functions for Xojo
Please remember to download the Microsoft Build tools and Unmanaged Exports by Robert Giesecke to have the dll work in Xojo.