SqlConnection Error if EXE is executed from network path

  • A+

First of all: everything you will read in this post happens only if Windows 10 April 2018 update is installed. No problem before installation and after update uninstallation.

After installing Windows 10 1803 update, all my VB program (VB6, .NET and WPF) running from network mapped drive or UNC path can't connect to SQL server, no problem if the same executable is placed and executed from local drive (tested on 2 pc in the same network):

  1. Remote SQL server, exe on local drive: OK
  2. Same remote SQL server, same exe on mapped network drive (with full read/write access): ERROR

This is the error (maybe not significat to solve this problem):

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified).

Simple VB.NET code to reproduce the problem (place the code in a simple form with a button in the button_click event, set values to connect to the SQL server, compile, save the exe file on a network path and execute it):

Dim myConnectionString As String Dim mySqlConnectionStringBuilder As New SqlConnectionStringBuilder() mySqlConnectionStringBuilder.DataSource = myServer mySqlConnectionStringBuilder.InitialCatalog = myDatabase mySqlConnectionStringBuilder.UserID = myUtente mySqlConnectionStringBuilder.Password = myPassword myConnectionString = mySqlConnectionStringBuilder.ConnectionString  Dim mySqlConnection As New SqlConnection(myConnectionString) mySqlConnection.Open()  <- error 


System.Data.SqlClient.SqlException (0x80131904): Si è verificato un errore di rete o specifico dell'istanza mentre si cercava di stabilire una connessione con SQL Server. Il server non è stato trovato o non è accessibile. Verificare che il nome dell'istanza sia corretto e che SQL Server sia configurato in modo da consentire connessioni remote. (provider: SQL Network Interfaces, error: 26 - Errore nell'individuazione del server/dell'istanza specificata)    in System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)    in System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)    in System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)    in System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)    in System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)    in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)    in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)    in System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)    in System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)    in System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)    in System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)    in System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)    in System.Data.SqlClient.SqlConnection.Open()    in RiepilogoOreTimer.RiepilogoOreTimerWindow.ConnessioneOK() ClientConnectionId:00000000-0000-0000-0000-000000000000 Error Number:-1,State:0,Class:20 

Any ideas?

Update: If I uninstall the April 2018 update the issue go away and the program works fine even if executed on a network drive, but this can't be the solution...

Update 08/05/2018: I noticed that April 2018 update brought some changes in security:

Windows 10, version 1803 provides additional protections:

  • New Attack surface reduction rules
  • Controlled folder access can now block disk sectors

Could it be the cause of the issue? I'm not a security manager so I can't say if this can cause my problem

Update 09/05/2018: I found this information in this post:

Windows 10 update 1803 does not open network connections on executables files on SMBv1 share (as Windows Server 2003)

but I don't know what SMBv1 is... somebody can help me?

Finally I found the focal point: the error raise only if I execute the program from a folder shared in a Windows Server 2008 R2, the same program executed on a Windows Server 2012 sahred folder works fine. So the problem is about SMBv1 share, deprecated starting from Windows 10 1803


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: