I developed a Web Api project in C # where I use entity framework, at the moment of executing this project in localhost, it worked correctly. At the time of passing this project to the IIS of the development environment it also worked, but when I passed it to the IIS of the QA environment I present the following error:
{
"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"
}
}
}
}
Been looking for this error and its possible solutions, I have tried several solutions but the error still persists. If anyone has already been through this, I would greatly appreciate your help.