Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll' in an environment and all ok in another #2089

Closed
davide882 opened this issue Jul 16, 2023 · 8 comments
Labels
⏳ Waiting for Customer Issues/PRs waiting for user response/action. 🔗 External Issue is in an external component

Comments

@davide882
Copy link

davide882 commented Jul 16, 2023

Good morning,
I have a .net framework 4.8 application that reference in the api project Microsoft.Data.SqlClient and Microsoft.Data.SqlClient.SNI.
All it's fine in my local machine and in our testing server, but when I deploy the application in the customer staging environment I get the error
Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

dll are there, so I can't understood why the application doesn't work in that environment: any ideas?

The complete stack trace of the exception is the following:

[DllNotFoundException: Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)]
   Microsoft.Data.SqlClient.SNINativeManagedWrapperX86.SNIInitialize(IntPtr pmo) +0
   Microsoft.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize(IntPtr pmo) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\Interop\SNINativeMethodWrapper.cs:799
   Microsoft.Data.SqlClient.SNILoadHandle..ctor() in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs:28
   Microsoft.Data.SqlClient.SNILoadHandle..cctor() in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs:19

[TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SNILoadHandle' threw an exception.]
   Microsoft.Data.SqlClient.TdsParser..cctor() in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\TdsParser.cs:181

[TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.TdsParser' threw an exception.]
   Microsoft.Data.SqlClient.TdsParser..ctor(Boolean MARS, Boolean fAsynchronous) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\TdsParser.cs:38
   Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:1838
   Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:1727
   Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, ServerCertificateValidationCallback serverCallback, ClientCertificateRetrievalCallback clientCallback, DbConnectionPool pool, String accessToken, SqlClientOriginalNetworkAddressInfo originalNetworkAddressInfo, Boolean applyTransientFaultHandling) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:539
   Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\SqlConnectionFactory.cs:143
   Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\ProviderBase\DbConnectionFactory.cs:148
   Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\ProviderBase\DbConnectionPool.cs:950
   Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\ProviderBase\DbConnectionPool.cs:2014
   Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\ProviderBase\DbConnectionPool.cs:1419
   Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\ProviderBase\DbConnectionPool.cs:1303
   Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\ProviderBase\DbConnectionFactory.cs:339
   Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\ProviderBase\DbConnectionInternal.cs:770
   Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\ProviderBase\DbConnectionClosed.cs:71
   Microsoft.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\SqlConnection.cs:2113
   Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\SqlConnection.cs:2101
   Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\SqlConnection.cs:1658
   Microsoft.Data.SqlClient.SqlConnection.Open() in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netfx\src\Microsoft\Data\SqlClient\SqlConnection.cs:1627
   Hangfire.SqlServer.SqlServerStorage.CreateAndOpenConnection() +208
   Hangfire.SqlServer.SqlServerStorage.UseConnection(DbConnection dedicatedConnection, Func`2 func) +50
   Hangfire.SqlServer.SqlServerStorage.UseConnection(DbConnection dedicatedConnection, Action`1 action) +71
   Hangfire.SqlServer.SqlServerStorage.Initialize() +185
   Hangfire.SqlServer.SqlServerStorage..ctor(String nameOrConnectionString, SqlServerStorageOptions options) +403
   Hangfire.SqlServerStorageExtensions.UseSqlServerStorage(IGlobalConfiguration configuration, String nameOrConnectionString, SqlServerStorageOptions options) +52
   Sgr.MyApp.WebAPI.Scheduler.HangfireBootstrapper.Start() in C:\Software\GBS\MyApp\Sgr.MyApp.WebAPI\Scheduler\HangfireBootstrapper.cs:36
   Sgr.MyApp.WebAPI.WebApiApplication.Application_Start() in C:\Software\GBS\MyApp\Sgr.MyApp.WebAPI\Global.asax.cs:125

[HttpException (0x80004005): The type initializer for 'Microsoft.Data.SqlClient.TdsParser' threw an exception.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +476
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +176
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +220
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +303

[HttpException (0x80004005): The type initializer for 'Microsoft.Data.SqlClient.TdsParser' threw an exception.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +659
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +89
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +189
@Kaur-Parminder Kaur-Parminder added the 🆕 Triage Needed For new issues, not triaged yet. label Jul 18, 2023
@Kaur-Parminder
Copy link
Contributor

@davide882 What is the type of the project? if this is a Web App, it is potential duplicate of existing issues. Please provide a Repro or steps to reproduce the issue.

@davide882
Copy link
Author

Hi, it's a web app in .net framework 4.8.
I don't know ho to reproduce the error: on my machine and on my company test server it works, on customer staging environment it doesn't work.

MyWebAPI.zip

@JRahnama
Copy link
Contributor

@davide882 so, from what I could understand inside the project in the path of bin/Release or debug/net48 you are able to see the required dll, but application is not able to find it?

@Kaur-Parminder Kaur-Parminder added ⏳ Waiting for Customer Issues/PRs waiting for user response/action. and removed 🆕 Triage Needed For new issues, not triaged yet. labels Jul 19, 2023
@David-Engel
Copy link
Contributor

You might be missing the VC runtime in that environment, required by the SNI DLL:
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022

@davide882
Copy link
Author

@davide882 so, from what I could understand inside the project in the path of bin/Release or debug/net48 you are able to see the required dll, but application is not able to find it?

Exactlty

@davide882
Copy link
Author

These are the vc installed on the customer enviroment
image002

@davide882
Copy link
Author

davide882 commented Jul 21, 2023

The application is developed with Visual Studio 2022 and in my enviroment, where all works correctly, I have the following VC installed.
Screenshot 2023-07-22 135953

It could be the missing Microsoft Visual C++ 2015-2022 Redistributable (x86 and x64) on the Customer environment the problem?

@David-Engel David-Engel added the 🔗 External Issue is in an external component label Jun 15, 2024
@David-Engel
Copy link
Contributor

Closing as duplicate of #446

@David-Engel David-Engel closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏳ Waiting for Customer Issues/PRs waiting for user response/action. 🔗 External Issue is in an external component
Projects
Development

No branches or pull requests

4 participants