Hi,
I looked into this. It seems that with .NET Core 3.1 when you publish, it will embed the native libraries by default, but starting in .NET 5.0 it does not - so even when you build a self-contained single-file app, you end up with all the native dlls alongside it.
Code: Select all
dotnet publish PhidgetTest -c Release -o ./out -p:PublishSingleFile=true -r win-x86 --self-contained true
Screenshot 2022-06-22 113135.png
This doesn't work - because the Phidget22.NET.dll has been embedded in the .exe, but the dll folder has not. Even though the dll folder is in the same directory as the .exe, the embedded Phidget22.NET.dll does not find it. I'll need to look at adding some additional search paths.
One option is to move the dll for your specified architecture alongside the .exe - ie move dll/x86/phidget22.dll to the same folder as the .exe, and then it's loaded as expected.
The other option is to include native libraries in the published .exe in .NET 6.0. You can set the
IncludeNativeLibrariesForSelfExtract flag to true, and the native libraries are embedded - but this does not work as expected for some reason - I'll need to look into it.
To get this working, you need to enable the .NET Core 3.1 behaviour, which is to extract ALL the files before running (in the background) by using the
IncludeAllContentForSelfExtract flag:
Code: Select all
dotnet publish PhidgetTest -c Release -o ./out -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true -r win-x86 --self-contained true
This produces the truly self-contained .exe which embeds the .NET and C phidget22 dlls.
-Patrick
You do not have the required permissions to view the files attached to this post.