找不到方法X509Chain.Dispose()

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了找不到方法X509Chain.Dispose()相关的知识,希望对你有一定的参考价值。

我的应用程序在本地环境中工作正常,但在生产服务器上不起作用。我得到了Exception“Method not found:'Void System.Security.Cryptography.X509Certificates.X509Chain.Dispose()'。”运行此代码时:

using (var responseMessage = await _httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead, context.RequestAborted))
{
    context.Response.StatusCode = (int)responseMessage.StatusCode;
    var response = await responseMessage.Content.ReadAsStringAsync();
    context.Response.Headers.Remove("transfer-encoding");
    await responseMessage.Content.CopyToAsync(context.Response.Body);
}

这是我的日志文件:

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
  Request starting HTTP/1.1 GET http://myserver.com:8080/anything 
fail: Microsoft.AspNetCore.Server.Kestrel[13]
  Connection id "0HLCB1RVBIPJL": An unhandled exception was thrown by the application.
System.MissingMethodException: Method not found: 'Void System.Security.Cryptography.X509Certificates.X509Chain.Dispose()'.
at XControl.HttpRequestHandlerMiddleware.<ProcessRequestAsync>d__5.MoveNext() in C:WorkingFolderHttpRequestHandlerMiddleware.cs:line 168
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at XControl.HttpRequestHandlerMiddleware.<Invoke>d__4.MoveNext() in C:WorkingFolderHttpRequestHandlerMiddleware.cs:line 36
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at XControl.XControlMiddleware.<Invoke>d__2.MoveNext() in C:WorkingFolderMiddleware.cs:line 22
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.<Invoke>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
  Request finished in 2256.0938ms 500 

这是我的project.json文件:

{
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "EntityFramework": "6.1.3",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net461": {
      "dependencies": {
        "Data": {
          "target": "project"
        }

      },
      "frameworkAssemblies": {
        "System.Configuration": "4.0.0.0"
      }
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "appsettings.json",
      "appsettings.Staging.json",
      "appsettings.Production.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

我的应用程序我使用.NET Framework版本在IIS 8中运行:无托管代码。

任何想法可能是什么问题?

答案

解决方案是让Windows更新完成它并更新clr版本。

以上是关于找不到方法X509Chain.Dispose()的主要内容,如果未能解决你的问题,请参考以下文章

找不到 X.509 证书 StoreName 'My'、StoreLocation 'LocalMachine'、FindType 'FindBySubjectName'、FindValue ''

关于 X509Certificate2 程序发布IIS后找不到文件路径的问题

致命错误:集成 firestore 后在 Flutter iOS 构建中找不到“openssl/x509.h”文件

WCF 上的 X.509 证书?

X509Certificate2.Import 与 NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG

如何从 PKCS#12 字节数组构造 X509Certificate2 抛出 CryptographicException(“系统找不到指定的文件。”)?