【发布时间】:2021-06-09 13:07:21
【问题描述】:
我有两个已发布的环境,一个用于测试,一个用于实时。 我发布的项目在测试环境中工作。没有任何问题,但是一旦我将它部署在实时环境中。 我收到以下错误:
ERROR 2021-06-08 16:45:34,415 455867ms ysomeController MoveNext - System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.TdsParser' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SNILoadHandle' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x64.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Microsoft.Data.SqlClient.SNINativeManagedWrapperX64.SNIInitialize(IntPtr pmo)
at Microsoft.Data.SqlClient.SNILoadHandle..ctor() in H:...\Microsoft\Data\SqlClient\TdsParserSafeHandles.cs:line 19
at Microsoft.Data.SqlClient.SNILoadHandle..cctor() in H:...\Microsoft\Data\SqlClient\TdsParserSafeHandles.cs:line 17
--- End of inner exception stack trace ---
at Microsoft.Data.SqlClient.TdsParser..cctor() in H:...\Microsoft\Data\SqlClient\TdsParser.cs:line 177
--- End of inner exception stack trace ---
at Microsoft.Data.SqlClient.TdsParser..ctor(Boolean MARS, Boolean fAsynchronous) in H:...\Microsoft\Data\SqlClient\TdsParser.cs:line 38
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) in H:...\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:line 1831
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) in
更新:我还应该提到 Microsoft.Data.SqlClient.SNI.x64.dll 在部署后存在于 \bin 中。
【问题讨论】:
-
请尝试Nuget包更新Microsoft.Data.SqlClient.SNI.x64并更新VS和OS最新版本。
-
再次检查您的应用程序配置(如果使用 IIS,您实际上是作为 Web 应用程序运行)以验证
bin文件夹实际上是在搜索二进制文件。
标签: .net sql-server asp.net-core