【发布时间】:2020-03-17 01:28:14
【问题描述】:
我在 C# 中使用实体框架开发了一个 Web Api 项目,在 localhost 中执行该项目时,它工作正常。在将此项目传递给开发环境的 IIS 时,它也可以工作,但是当我将它传递给 QA 环境的 IIS 时,出现以下错误:
{
"Message": "An error has occurred.",
"ExceptionMessage": "The type initializer for 'Microsoft.Data.SqlClient.TdsParser' threw an exception.",
"ExceptionType": "System.TypeInitializationException",
"StackTrace": " at ConsultaCuentaCupon_Api.Controllers.ConsultaCuponClienteController.<Post>d__0.MoveNext() in C:\\Users\\nflores\\source\\repos\\ConsultaCuentaCupon-Api\\ConsultaCuentaCupon-Api\\Controllers\\ConsultaCuponClienteController.cs:line 53\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__1`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "The type initializer for 'Microsoft.Data.SqlClient.SNILoadHandle' threw an exception.",
"ExceptionType": "System.TypeInitializationException",
"StackTrace": " at Microsoft.Data.SqlClient.TdsParser..cctor() in E:\\agent1\\_work\\34\\s\\src\\Microsoft.Data.SqlClient\\netfx\\src\\Microsoft\\Data\\SqlClient\\TdsParser.cs:line 156",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "The type initializer for 'Microsoft.Data.SqlClient.SNINativeMethodWrapper' threw an exception.",
"ExceptionType": "System.TypeInitializationException",
"StackTrace": " at Microsoft.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize()\r\n at Microsoft.Data.SqlClient.SNILoadHandle..ctor() in E:\\agent1\\_work\\34\\s\\src\\Microsoft.Data.SqlClient\\netfx\\src\\Microsoft\\Data\\SqlClient\\TdsParserSafeHandles.cs:line 31\r\n at Microsoft.Data.SqlClient.SNILoadHandle..cctor() in E:\\agent1\\_work\\34\\s\\src\\Microsoft.Data.SqlClient\\netfx\\src\\Microsoft\\Data\\SqlClient\\TdsParserSafeHandles.cs:line 16",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Failed to load C:\\inetpub\\wwwroot\\CuponCliente-API\\bin\\x64\\SNI.dll",
"ExceptionType": "System.ComponentModel.Win32Exception",
"StackTrace": " at Microsoft.Data.SqlClient.SNINativeMethodWrapper..cctor() in E:\\agent1\\_work\\34\\s\\src\\Microsoft.Data.SqlClient\\netfx\\src\\Microsoft\\Data\\Interop\\SNINativeMethodWrapper.cs:line 66"
}
}
}
}
一直在寻找此错误及其可能的解决方案,我尝试了多种解决方案,但错误仍然存在。如果有人已经经历过这种情况,我将非常感谢您的帮助。
【问题讨论】:
标签: c# entity-framework ado.net