AaronRobinsonMSFT / DNNE

Prototype native exports for a .NET Assembly.
MIT License
394 stars 41 forks source link

<RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers> not work as except #170

Open gitlsl opened 1 year ago

gitlsl commented 1 year ago

dnne 2.0.1 vs2022 win11

q1: I see your example https://github.com/AaronRobinsonMSFT/DNNE/blob/cd55d290c56c022a7a73b48f0ecf232546bee6e3/sample/Sample.csproj#L14 after my try <RuntimeIdentifier>win-x64</RuntimeIdentifier> work as except but Adding the RuntimeIdentifiers resulted in the same result as not adding one

q2:

  [UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvStdcall) })]
            public static int MyExport(int a)
            {
                xxx();
                return a;
            }

simple export one funcuton, the generated DLL file is 1mb(release version). Is this right size or I miss something

AaronRobinsonMSFT commented 1 year ago

Adding the RuntimeIdentifiers resulted in the same result as not adding one

Did you have all target runtimes installed? @ThaDaVos were you cross-targeting runtimes with RuntimeIdentifiers or something else?

simple export one funcuton, the generated DLL file is 1mb(release version). Is this right size or I miss something

The native export itself is very small, but we need to link in logic for nethost.lib that is provided by the .NET hosting layer. It also has additional dependencies and it does increase the size.

ThaDaVos commented 1 year ago

Adding the RuntimeIdentifiers resulted in the same result as not adding one

Did you have all target runtimes installed? @ThaDaVos were you cross-targeting runtimes with RuntimeIdentifiers or something else?

simple export one funcuton, the generated DLL file is 1mb(release version). Is this right size or I miss something

The native export itself is very small, but we need to link in logic for nethost.lib that is provided by the .NET hosting layer. It also has additional dependencies and it does increase the size.

I was targetting using DnneRuntimeIdentifier instead of RuntimeIdentifiers - this leaves the .net dll multi-arch and only restricts the DNNE dll - I targetted with <DnneRuntimeIdentifier>win-x86</DnneRuntimeIdentifier> - but I do have both SDK versions installed, 32 and 64 bit