Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export of C# class library fails in Visual Studio 2019

I have a solution that have multiple projects. One of them is a class library (C# - .Net Framework), and this dll needs to be exported as unmanaged code to use in C++ project. Before migration for VS 2019, i do that with the VS2017 and everything worked fine, but now with the 2019 version i have some incompatibilities that i can't solve. For the DLL exportation we use a library called "Unmanaged Export" of RGiesecke that works perfectly in VS2017.

For solve this issue i tried to downgrade the version of .Net Framework to 4.6.2 and 4.0. I tried to downgrade the version of package and don't work neither. I have all .Net Framework versions installed since 3.5 version.

This is a demonstrative example of the code to export a function. This works perfectly in VS2017 with 4.6.2 .Net version!

namespace ExampleExp
{
    public class ExportInterfaceEx
    {

        [DllExport(CallingConvention = CallingConvention.Cdecl)]
        public static int Start()
        {
            return 5;
        }

    }
}

I have this error when i try to compile the class library:

The "DllExportAppDomainIsolatedTask" task failed unexpectedly. System.ArgumentException: Requested value 'Version47' was not found.

like image 362
Marco Teixeira Avatar asked Oct 22 '25 17:10

Marco Teixeira


2 Answers

I have been experiencing the same issue myself.

Best information I've been finding on this is here; https://github.com/3F/DllExport/issues/29

Suggest you ensure you, first, have the latest version of UnmanagedExports (1.2.7 at the moment by NuGet store). You could try installing build tools as suggested in this thread, though installing said tools for VS2015 and VS2019 didn't work for me.

For me lowering the targeted .NET framework of the project down .NET 4.5 works, but doesn't work for 4.7.2...

like image 77
P.Wright Avatar answered Oct 25 '25 06:10

P.Wright


You can use DllExport instead of UnmanagedExports as it is out of date.

like image 21
pansila Avatar answered Oct 25 '25 05:10

pansila



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!