存储在网络驱动器上的 EXE 的 SqlConnection 错误

SqlConnection Error for EXE stored on network drive

.Net 控制台 EXE 的执行总是失败并出现以下错误,只有当 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).

如有任何帮助,我们将不胜感激。

好的,关键是你说的 "when schedule task execute the same exe it fails with SqlConenction error"。如果您在 Windows 计划程序下 运行 执行此任务,请确保 Windows 计划作业是 运行 正确的凭据。默认情况下,他们 运行 在 Windows 服务下,无权连接到 SQL 服务器。使用特定的帐户名和密码设置 Windows 计划任务。

发现“路径层次结构中顶级目录缺少权限”的问题。 在为顶级目录提供适当的权限后,EXE 能够连接到 SqlServer。 似乎在没有此类权限的情况下,安全策略限制了应用程序访问网络资源。