I'm trying to publish a very simple C# .Net 5.0 WinForms application (single file output) as a test case for porting from the .Net Framework v4.6.1 (what it was previously) while using Visual Studio 2019 v16.8.2. The Publish options are as follows:
Although the build works fine and merges the two source assemblies into a single output executable, it also includes SNI.dll in the output directory. The application will not start without this DLL in the same folder as the executable so my question is: How do I remove the dependency on SNI.dll so it does not get included with the published executable and is not required to run?
The application is a simple front-end to generate random data using the Crypto-API. It does not include any database functionality whatsoever, which is why it's so confusing to me that SNI.dll is included in the output. As far as I can tell, SNI.dll is related to Microsoft.Data.SqlClient, which I don't use
Any help with this would be most appreciated. Cheers
PS. I should mention, all my attempts to Google this fault have turned up articles about "SNI.dll Missing", "SNI.dll failed to load" or some other variant of that
R2R is a form of ahead-of-time (AOT) compilation. R2R binaries improve startup performance by reducing the amount of work the just-in-time (JIT) compiler needs to do as your application loads. The binaries contain similar native code compared to what the JIT would produce.
dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. The output includes the following assets: Intermediate Language (IL) code in an assembly with a dll extension.
I faced the same problem as yours and found the solution here. It turns out that native libraries are not bundled in the single file executable by default. You must set the flag IncludeNativeLibrariesForSelfExtract
to true
to get this behavior.
You might also want to check your .deps.json file (from your build folder) to see how you got this dependency in the first place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With