Using .NET Framework DLL's in Xojo

I have seen a few other posts on this forum in regards to using a DLL in Xojo, one in particular was todo with a .NET DLL (Not sure if it was a Framework or just .NET DLL). I have a query to a .NET framework DLL (.NET 4.7.2) called Easymodbus.dll. I am trying to use this in Xojo for an application but the standard declare method does not work due to the DLL not exporting any modules etc because it is a framework class library. Is this correct? and is there a work around in Xojo for this. The library works fine in VS 2022 with a .NET framework (4.7.2) VB app but not with a .NET (7.0) VB app.
The error message in Xojo is ‘cannot find function xxx in easymodbus.dll’

I attempted this about 6 weeks ago and I might as well share what I found…

There’s a few references out there about exposing .NET dlls for use with Win32 apps, but they all point to a single VS plugin from 8-10 years ago for exporting the DLL names correctly. That plugin does not work in modern versions of VS, I was only able to even try it in VS 2015 and it was already flakey there. If you do manage to get it working, you’ll basically need to create a bridge or a wrapper class which exposes all the things you’ll need to access.

More info can be found here

Thanks Greg :slight_smile:

The .NET component must be compiled with COM registration. So if you did not make the .NET component and it does not have COM registration then you will not be calling managed code which .NET is from non managed code (which Xojo is).

However in such case then you still could bridge it by creating your own .NET component that calls the 3rd party .NET component. And your .NET component would be compiled with COM registration.

1 Like

I have had some success with the upgraded versions of UnmanagedExports.