C# dll

How can I include a C# DLL in XOJO? I tried the following, but did not work.

XOJO Code:

Declare Function AddTwo Lib "Test.dll" (a as Integer, b as Integer) As Integer
res = AddTwo(2,3)

Test.dll C# Code :

namespace Test
{
    public class Test_Class
    {
        public static int AddTwo(int a, int b)
        {
            return a + b;
        }
    }
}

BR
Sebastian

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:

Or write your DLL in Rust or C directly.

Hello @Sebastian_Fischer1,

For my AddTwo example, please follow the instructions at my website at: Create a CSharp DLL for Xojo

There is example code that can be downloaded with my Github account at: https://github.com/eugenedakin/CSharpDLLXojo

Please remember to download the Microsoft Build tools and Unmanaged Exports by Robert Giesecke to have the dll work in Xojo.

Warm regards. :slight_smile:

2 Likes