Calling X-Plat C# library in Xojo

Maybe it still requires some COM interop dancing as in the “old days”?

Sure. Here is a C++ dll that I just created called MeestorDLL.dll that has two external functions: AddTwo (adds two numbers together), and GetAString, which returns the string Hello World!

Click to download code here: Xojo and C++ Demo Code


1 Like

Nice one, @eugenedakin!

But… I meant c++ calling a function in the c# dll we’ve been looking at.
If c++ can call the c# functions without any trouble, then we know the issue is how the c# functions are presented to Xojo, and there might be hope for a c++ “bridge” between them.

I found this, not sure if it’s helpful?

I misunderstood, thanks for clarifying about a C++ bridge. I’ll look into this a little more.

This (the source of the files you’ve been working with) will likely help even more:

There’s a C++ example there, I believe.

Seeing how C++ calls the C# library functions may illuminate how to conform the C# file to work with Xojo, or how to conform Xojo to work with it.
Or, a small C++ bridge could be created between Xojo and the C# library that somehow covers passing the various types back and forth. (MemoryBlocks and Pointers would be the most useful…)

Hi Andy,

I have good news, as I can now create a C# DLL directly with Visual Studio 2019 and have the external functions work in Xojo 2020 r1.

Here are the instructions on how to create a CSharp and Xojo file:
[Create a CSharp DLL ](

Here is the Github project with all the files:

Here is a running screen grab:

Let me know if it works on your computer :slight_smile:

Ah, so you got my original link from my first post working! Well done, but that one was known to be working a while ago, but for Windows only.

I had that working too (until I messed something up).
The real issue with that library is I could not get it working on MacOS, which is why I was looking at the newer solution in my later posts.

Were you able to figure out anything that works on MacOS?

I tried quite a few ways on Mac, and wasn’t able to get it to work. I am sure it is because I am not familiar with a Mac.

I appreciate your efforts on this, @eugenedakin.
So, sticking with Windows for a moment, are you able to call functions in the later .NET5 C# DLL from C++?

@npalardy, how’s your C++? Are you able to call the .NET5 C# DLL with C++ under MacOS?

Just checking in, I imagine you’re both very busy, but I’m still keenly interested in finding a X-Plat way to call C# library functions, if either of you have any additional insight?

I dont

It doesnt seem to generate a “standard” dylib on macOS that can be loaded

Xojo doesnt do anything truly special with a dylib
It basically calls dlopen to load it and then the various “declares” call the exposed entry points in that dll
That the C# isnt loading suggests it needs something “special” beyond this

What that is I have no idea

Understood. Thanks for the info.

Just to clarify, I think the .dylib does load, it’s just that Xojo can’t call the functions. That’s why I’m curious if C++ has better luck instead of Xojo, but alas I never learned C++!

Hey there :slight_smile:
I have tried a few different examples and I can’t seem to understand their instructions. Sorry, no progress to report.

Edit: LOL, like the other example, there is likely a button that I need to press, a checkbox to check or something like that, which is not included in the instructions.

I am not able to select .NET Framework 5.0 as a Target Framework, as .NET 5 is still being worked on.

From the below website:
Introducing .NET 5
It appears that November 2020 will be the final release date:

We will ship .NET Core 3.0 this September, .NET 5 in November 2020, and then we intend to ship a major version of .NET once a year, every November

Maybe this is when I can give it a try to be fully implemented into the Visual Studio IDE? I just can’t seem to get it to appear in the development stage.

Tools/Options/Environment/Preview Features
Check “Use previews of the .NET Core SDK”

Of course, you have to have added the .NET5 Core SDK as well.

In the Project properties, you change whatever is listed under

It’s not AT ALL straightforward and I spent a lot of time messing with this stuff to get things working.

Do you figure we’ve gone as far as we can with this?

I have tried, and no luck so far. Sorry.