SqlClient: Unable to load DLL 'sni.dll'
We are seeing a number of folks hitting the Unable to load DLL 'sni.dll' issue with the latest RC2 builds. Folks are hitting this when using EF Core but have confirmed that the issue exists when working directly with SQL Client too.
See https://github.com/aspnet/EntityFramework/issues/4953 for a good description from someone hitting the issue.
cc @mrmeek who filed the above issue
@saurabh500 @YoungGah @corivera : blocking rc2 bug
Looking into it.
We are hitting it on aspnetci servers too. Win Server 2008 R2. I've attached a sample lockfile. project.lock.json
@natemcmaster when did you start facing this issue?
cc @ericstj
We just noticed it this morning. SqlClient 4.1.0-rc2-23931
//cc @weshaggard I double checked the lock file and the packages and confirm that the DLL is correct bitness and references msvcrt.dll. @natemcmaster if you run depends on the SNI.dll on the machine that's failing it should show you what's missing. I'm reviewing the dependencies now against what I see in the project.lock.json to make sure we aren't missing some api-set dll.
I double checked all the API set dependencies and they are satisfied. @schellap perhaps something wrong with how the host is setting up paths for PInvoke.
This may also be part of it. From @BrennanConroy:
I see that it started as soon as we grabbed version 2202 of the CLI
@natemcmaster, can you point me to the project that reproes it.
https://github.com/aspnet/Diagnostics/blob/0a444088c9a7c5c6b4073c92104b48af734ef523/test/Microsoft.AspNetCore.Diagnostics.FunctionalTests/DatabaseErrorPageSampleTest.cs#L24
I can consistently repo on a Win Server 2008 R2 box, but not my local machine. Contact me internally and I can point you to the right box.
git clone https://github.com/aspnet/Identity
cd Identity
dotnet restore --infer-runtimes
cd test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
dotnet test
cc @saurabh500
Could this be another problem with missing a redist?
That DLL compiles against msvcrt.dll which isn't the redist CRT: it should be part of the OS. If you try depends.exe on the dll on the target machine it will tell you if anything is missing.
@mrmeek What OS are you running your app on ?
What is puzzling to me at this point is:
Property NATIVE_DLL_SEARCH_DIRECTORIES = C:\Users\asplab\.nuget\packages\Microsoft.DiaSymReader.Native\1.3.3\runtimes\w
in-x64\native;C:\Users\asplab\.nuget\packages\runtime.win7-x64.Microsoft.NETCore.DotNetHost\1.0.0-rc2-00001\runtimes\wi
n7-x64\native;C:\Users\asplab\.nuget\packages\runtime.win7-x64.Microsoft.NETCore.DotNetHostPolicy\1.0.0-rc2-00001\runti
mes\win7-x64\native;C:\Users\asplab\.nuget\packages\runtime.win7-x64.Microsoft.NETCore.DotNetHostResolver\1.0.0-rc2-000
01\runtimes\win7-x64\native;C:\Users\asplab\.nuget\packages\runtime.win7-x64.Microsoft.NETCore.Runtime.CoreCLR\1.0.2-rc
2-23931\runtimes\win7-x64\native;C:\Users\asplab\.nuget\packages\runtime.win7-x64.Microsoft.NETCore.Windows.ApiSets\1.0
.1-rc2-23931\runtimes\win7-x64\native;C:\Users\asplab\.nuget\packages\runtime.win7-x64.runtime.native.System.Data.SqlClient.sni\4.0.1-rc2-23931\runtimes\win7-x64\native;
The last one contains the dir where the sni.dll is present.
I ran depends.exe with the folders listed in NATIVE_DLL_SEARCH_DIRECTORIES. The tool says it's still missing some modules.

Also disclaimer: I'm new at the tool so the results may not be 100% accurate.
We can double check that one of these is causing the actual load failure using procmon.
Here is the procmon dump on dotnet.exe. Not sure which needle in this haystack to look for. Logfile.zip
I think you need to monitor corehost.exe
Could it the error be caused by one of these events? https://gist.github.com/natemcmaster/3349e792a62520cfb3c3a9297dd4b5e0 I pulled these from the full procmon dump for corehost: corehostexe_procmon.zip