runtime icon indicating copy to clipboard operation
runtime copied to clipboard

SqlClient: Unable to load DLL 'sni.dll'

Open rowanmiller opened this issue 10 years ago • 49 comments

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

rowanmiller avatar Apr 05 '16 17:04 rowanmiller

@saurabh500 @YoungGah @corivera : blocking rc2 bug

joshfree avatar Apr 05 '16 17:04 joshfree

Looking into it.

saurabh500 avatar Apr 05 '16 17:04 saurabh500

We are hitting it on aspnetci servers too. Win Server 2008 R2. I've attached a sample lockfile. project.lock.json

natemcmaster avatar Apr 05 '16 17:04 natemcmaster

@natemcmaster when did you start facing this issue?

cc @ericstj

saurabh500 avatar Apr 05 '16 17:04 saurabh500

We just noticed it this morning. SqlClient 4.1.0-rc2-23931

natemcmaster avatar Apr 05 '16 17:04 natemcmaster

//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.

ericstj avatar Apr 05 '16 17:04 ericstj

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.

ericstj avatar Apr 05 '16 17:04 ericstj

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 avatar Apr 05 '16 17:04 natemcmaster

@natemcmaster, can you point me to the project that reproes it.

schellap avatar Apr 05 '16 17:04 schellap

https://github.com/aspnet/Diagnostics/blob/0a444088c9a7c5c6b4073c92104b48af734ef523/test/Microsoft.AspNetCore.Diagnostics.FunctionalTests/DatabaseErrorPageSampleTest.cs#L24

BrennanConroy avatar Apr 05 '16 18:04 BrennanConroy

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

natemcmaster avatar Apr 05 '16 18:04 natemcmaster

Could this be another problem with missing a redist?

natemcmaster avatar Apr 05 '16 18:04 natemcmaster

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.

ericstj avatar Apr 05 '16 18:04 ericstj

@mrmeek What OS are you running your app on ?

saurabh500 avatar Apr 05 '16 18:04 saurabh500

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.

schellap avatar Apr 05 '16 18:04 schellap

I ran depends.exe with the folders listed in NATIVE_DLL_SEARCH_DIRECTORIES. The tool says it's still missing some modules. image

Also disclaimer: I'm new at the tool so the results may not be 100% accurate.

natemcmaster avatar Apr 05 '16 18:04 natemcmaster

We can double check that one of these is causing the actual load failure using procmon.

ericstj avatar Apr 05 '16 18:04 ericstj

Here is the procmon dump on dotnet.exe. Not sure which needle in this haystack to look for. Logfile.zip

natemcmaster avatar Apr 05 '16 19:04 natemcmaster

I think you need to monitor corehost.exe

ericstj avatar Apr 05 '16 19:04 ericstj

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

natemcmaster avatar Apr 05 '16 19:04 natemcmaster