Code: Select all
[UnmanagedCallersOnly(EntryPoint ="AddOne")]
public static int AddOne(int x)
{
Console.WriteLine("Inside AddOne");
return x + 1;
}
Code: Select all
dotnet publish -f net8.0 -c Debug -r win-x64 -p:PublishAot=true -p:NativeLib=Shared -p:SelfContained=true
Die Hostanwendung ist eine .net Framework-Konsolenanwendung. Ich verwende die DLL mit diesem Code:
Code: Select all
[DllImport("ClassLibrary.dll")]
private static extern int AddOne(int x);
Was mache ich falsch?
Der vollständige Quellcode ist in diesem Commit enthalten:
https://github.com/JYPDWhite/DllExportT ... 15a79dd3c3