3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
937 stars 131 forks source link

Is .Net Standard 2.0 supported? #214

Closed Saya47 closed 1 year ago

Saya47 commented 1 year ago

Hello I'm using VS 2019, I created a new .Net Standard Class Library C# project targeting netstandard2.0. I installed DllExport: dotnet add package DllExport --version 1.7.4 And wrote a small code:

using CoreAudio;
using System;
using System.Collections.Generic;
using static System.Console;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;

namespace MyTests
{
    public class ExportProgram
    {
        //[DllExport]
        [DllExport("Init", CallingConvention.StdCall)]
        public static string TestExport()
        {
            return "999";
        }
    }
}

I get this warning during the build: warn : 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' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.

I can't see the functions on the dll using dumbin /exports.

But on the other hand, .Net Framework has no issue and DllExport works just fine, I can see the exported function using dumpbin /exports and I can call it using rundll32. And I used the code below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CoreAudio;
using static System.Console;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace MyTests
{
    public class ExportProgram
    {
        //[DllExport]
        [DllExport("Init", CallingConvention.StdCall)]
        public static string TestExport()
        {
            MessageBox.Show("Hello, world, from C#!");
            return "999";
        }
    }
}
Saya47 commented 1 year ago

Well, I have no idea why it installed UnamagedExports along with DllExport, I didn't tell it to do that :/

Saya47 commented 1 year ago

Just one question how do I add a reference to DllExport? I don't see anything: image

3F commented 1 year ago

Hello,

Yes .NET Standard 2.0 is supported https://github.com/3F/DllExport/wiki/.Net-Core

Please follow the information from the issue template and provide requirement data to diag your case.

Please also read https://github.com/3F/DllExport/wiki/Quick-start

> "warn : Package 'UnmanagedExports 1.2.7' was restored using..."

Also make sure you only use DllExport tool and not UnmanagedExports.1.2.7 https://github.com/3F/DllExport/issues/196#issuecomment-996028881

You need to edit it manually if your project file is corrupted somehow or simply try to delete everything before continue. Then follow steps from the wiki.

n. I may be slow to respond due to many reasons beyond my control,     sorry

Saya47 commented 1 year ago

I see, thanks very much.

3F commented 1 year ago

Hello,

Yes .NET Standard 2.0 is supported https://github.com/3F/DllExport/wiki/.Net-Core

Please follow information from the issue template and provide requirement data to diag your case.

Please also read https://github.com/3F/DllExport/wiki/Quick-start

warn : Package 'UnmanagedExports 1.2.7' was restored using...

Also make sure you only use DllExport and not UnmanagedExports.1.2.7 https://github.com/3F/DllExport/issues/196#issuecomment-996028881

You need to edit it manually if your project file is corrupted somehow or simply try to delete everything. Then follow steps from the wiki.

n. I can be very slow for many reason in response, sorry