简体   繁体   English

无法加载 SNI.dll

[英]Failed to load SNI.dll

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.我在 C# 中开发了一个 Web Api 项目,其中使用了实体框架,在 l​​ocalhost 中执行该项目时,它工作正常。 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:在将这个项目传递给开发环境的 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"
            }
        }
    }
}

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.如果有人已经经历过这个,我将非常感谢你的帮助。

我必须在服务器上安装“Microsoft Visual C++ 2015-2019 Redistributable”(在我的情况下为 x64),但它无法处理您提到的错误消息。

I had a different Situation for this Error, maybe it helps someone:我对此错误有不同的情况,也许它可以帮助某人:

  • I was running a Web-Application in IIS (Internet Information Server)我在 IIS(Internet 信息服务器)中运行 Web 应用程序
  • The Application-Pool was set up with my Credentials应用程序池是用我的凭据设置的
  • I changed my Password last week我上周更改了密码

and the Result was that the Application was still starting, but this confusing exception appeared when trying to connect the the Database:结果是应用程序仍在启动,但是在尝试连接数据库时出现了这个令人困惑的异常:

Failed to load SNI.dll not found or pemission denied

Removing the App-Pool User and re-entering with the new Password helped.删除 App-Pool 用户并使用新密码重新输入有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM