gpt4 book ai didi

sql-server - 如果从网络路径执行 EXE,则 SqlConnection 错误

转载 作者:行者123 更新时间:2023-12-02 02:14:24 25 4
gpt4 key购买 nike

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.

安装 Windows 10 1803 更新后,从网络映射驱动器或 UNC 路径运行的所有 VB 程序(VB6、.NET 和 WPF)无法连接到 SQL Server,如果从本地放置并执行相同的可执行文件,则没有问题驱动器(在同一网络中的 2 台电脑上测试):

  1. 远程 SQL 服务器,本地驱动器上的 exe:确定
  2. 相同远程 SQL 服务器,映射网络驱动器上相同 exe(具有完全读/写访问权限):错误

这是错误(也许对解决这个问题没有意义):

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

重现问题的简单 VB.NET 代码(将代码放在简单的形式中,并在 Button_click 事件中添加一个按钮,设置值以连接到 SQL 服务器,编译,将 exe 文件保存在网络路径上并执行):

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

异常(exception):

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

有什么想法吗?

更新:如果我卸载 2018 年 4 月更新,问题就会消失,即使在网络驱动器上执行,程序也能正常工作,但这不是解决方案...

2018 年 8 月 5 日更新:我注意到 2018 年 4 月更新带来了一些 changes in security :

Windows 10, version 1803 provides additional protections:

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

这可能是问题的原因吗?我不是安全经理,所以我不能说这是否会导致我的问题

更新 09/05/2018: 我在 this 中找到了此信息帖子:

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

但我不知道 SMBv1 是什么...有人可以帮助我吗?

最佳答案

最后我发现了问题:在共享文件夹的服务器中,SMBv2被禁用(我不知道为什么),所以只有SMBv1处于事件状态;从同一网络中的同一客户端执行但位于启用了 SMBv2 的服务器上的同一程序可以正常工作。

所以问题与 SMBv1 共享有关,从 Windows 10 1803 开始​​已弃用

关于sql-server - 如果从网络路径执行 EXE,则 SqlConnection 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50172067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com