Call .NET 8.0 DLL from Clarion 10 application


I have been using a .NET Framework DLL in our Clarion application for many years without issues. We were recently forced to upgrade our library to .NET 8.0 due to a dependency update. Since the update, the Clarion app instantly crashes instantly when calling any of the exported DLL functions.

To simplify testing and remove variables, I have created a test app in Clarion 10 (using the Win32 EXE template) and a test library using the “CLR Class Library (.NET)” template in Visual Studio 2022.

I have tested linking to the library both statically (using both the built-in LibMaker.exe and LibMakerPlus from and also dynamically using the LoadLibrary() APIs without success. Note that when I create the same library from the “CLR Class Library (.NET Framework)” template in VS, both of the linking methods work without crashing.

Is there some extra configuration that I need to make in the .NET library to be compatible with Clarion?

My current library code looks like the following…

// Net.h
#pragma once

extern "C" __declspec(dllexport) int GetSeven();

// Net.cpp
#include "pch.h"
#include "Net.h"

int GetSeven()
	return 7;

I am compiling in release mode targeting x86.

My Clarion app code looks like the following…

! Main procedure
Main                 PROCEDURE                             ! Declare Procedure

  CODE                                                     ! Begin processed code
		MESSAGE('Done!')  ! This never gets called because Clarion crashes on the previous line

! Global map

I have generated the LIB file using LibMaker.exe (the function shows up correctly in the preview) and added the library in the Solution Explorer.

I have been stuck on this for weeks, so any help would be greatly appreciated!

Thank you,

There’s a Nuget package called Unmanaged Exports that I’ve used for a long time to call . NET methods. There’s a ClarionMag article that covers its use.

Maybe that will help.

I recently had to swap the UnmanagedExport for the DllExport package, because at some point of version of .net, it stopped exporting methods. Also, the DllExport is on github and seems actively supported.


Thank you for the suggestions. I attempted to create a brand new C# Class Library (using .NET 8.0 framework).

The UnmanagedExports package gives the following warning when installed…

Severity	Code	Description	Project	File	Line	Suppression State	Details
Warning	NU1701	Package 'UnmanagedExports 1.2.7' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.

I am struggling with the DllExport package. Do you remember which settings you configured in the GUI that pops up right after installation?

I am not using UnmanagedExports, but the DllExport package.
I found the DllExport.bat somewhere and put that in my project directory.
The most important thing is the x86 setting. I have used different values for namespace, I have had trouble with the one “System.Runtime.Interop.Services”, but not with the ones with projectname.