Marco Teixeira
Marco Teixeira

Reputation: 127

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.

Upvotes: 4

Views: 4107

Answers (2)

pansila
pansila

Reputation: 177

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

Upvotes: 1

P.Wright
P.Wright

Reputation: 71

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...

Upvotes: 3

Related Questions