SqlClient for Windows: Native SNI depends on MSVCR110.dll
Using SqlClient can cause a DllNotFoundException on sni.dll. This has been reported a few times by customers trying to use SqlClient on coreclr-x64/x86 on Windows (see aspnet/Home#904 for detailed symptoms). One of the possible causes is that you may need the Microsoft Visual C++ 2012 Redistributable installed to get SqlClient to work.
Beta8 has not solved the problem, e.g. link /dump /imports sni.dll still shows MSVCR110.dll in the list of dependencies.
From an email thread with @ericstj it seems that it should use msvcrt.dll instead.
Note that the msvcr110.dll dependency will likely prevent SqlClient from working on Nano server, that would be pretty lame.
@divega that's correct. We build clrcompression.dll against msvcrt.dll today. Sni.dll needs to do the same. You should be able to control this in your project settings for SNI.dll.
/cc @weshaggard
I looked at the sni.dll implementation and there are usages of _dupenv_s at three locations. The _dupenv_s (...) function is used to retrieve the envrionment variables on windows. The implementation of NamedPipe provider and resolution of SQL Server instance names on windows need to query the environment variables.
Apart from the dependency on the above function, the build properties should be changed to refer the C runtime from the Windows core system runtime.
Another note: The _dupenv_s () function is used to retrieve the CLUSTER_NETWORK_NAME
@mikedn As far as the Nano Server is concerned, this bug is not relevant. We need to build Managed SNI based SqlClient for Nano server. Currently the dlls generated for Linux and OSX are managed SNI based where TCP connectivity has been implemented.
@saurabh500 How would the managed SNI version would be selected on Nano server? As far as I can tell the managed SNI is selected at compile time so it would seem that we need different a SqlClient assembly for Nano, that may be a bit cumbersome.
@mikedn yes the managed SNI is built at compile time. The managed SNI is being developed to have parity with native SNI. Currently for windows we are using native SNI so that the features on windows are maintained. Once managed SNI is at par with native SNI we want to retire the native SNI in CoreFx. This will allow us to run the managed version across different platforms.
@saurabh500 Sounds good, thanks for the information.
I have installed Microsoft Visual C++ 2012 Redistributable, but this does not seem to resolve the issue on coreclr-x64-rc1-update1 with Windows Server 2008 R2.
@divega Are there any other workaround or solutions available yet?
@juswes did you run this inside IIS ?
This issue seems to be related with https://github.com/dotnet/corefx/issues/5252
After installing VS C++ 2012 Redistributable still not solve the problem if the application is running inside IIS
@KKhurin Correct, it only occurs when you run a published version of your web app in IIS on Windows Server 2008 R2. If you use the "web" comment from the command line the app works fine. I now installed everything on a Windows Server 2012 R2 server and then I can publish to IIS and run the web app just fine. So it seems this issue only occurs if you publish it to a Windows 2008 R2 server and run it in IIS.
Any workarounds at this time? I want to publish a webapp to Azure services, I have no control on what version of Win Server they are using?
Thank you!
This is affecting my project as well. It's strange, because it works when I execute dnx web from command-line, but when I try to press play from Visual Studio, the error occurs when I try using the SqlClient class (while attempting to log into an account within the website).
I just reformatted my Windows 7 laptop with a new clean copy of Win 7 Pro + Visual Studio 2015 Community Edition, and this error has only happened on the new install. Before reformatting, the project worked just fine. I'm using rc1-final x64 coreclr.
A fix was delivered into TFS to remove the dependency of sni.dll on mscvcr110.dll
I just had this error for the first time, after the latest Windows 10 update was automatically installed. I resolved it by copying msvcr110.dll into c:\windows. I found using process explorer that it wasn't able to find it, presumably the update 'updated' it.
Is there a fix for this issue? I'm still seeing it in my application deployed on AWS using IIS or by launching the application through the command line using the "web" command. I also confirmed the DLL is where it should be in the inetpub folder.
This issue was fixed and SqlClient doesn't need MSVCR110.dll to run anymore.
What is the error that you are receiving? Also what version of Windows are you using for your service?
I'm using Windows 7 on my dev machine and the application runs fine on Visual Studio 2015. When I publish it and deploy the application on my AWS Windows Server 2012 R2 server (IIS), i get this issue. I've also verified that the sni.dll file is in the path shown on the error message.
The error i'm getting is:
DllNotFoundException: Unable to load DLL 'C:\inetpub[app]\approot\packages\runtime.win7-x64.System.Data.SqlClient.sni\4.0.0-beta-23516\runtimes\win7-x64\native\sni.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
@tsiqueira86 You are using a very outdated package there, pre-RC1 even. If you update to the RTM tools and packages, the problem will go away. There's nothing we can do unless this happens...the fix is in the updated packages.