未找到方法 X509Chain.Dispose()

Method not found X509Chain.Dispose()

我的应用程序在本地环境中运行良好,但在生产服务器上无法运行。当 运行 此代码时,我得到异常 "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:\WorkingFolder\HttpRequestHandlerMiddleware.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:\WorkingFolder\HttpRequestHandlerMiddleware.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:\WorkingFolder\Middleware.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%" ]
  }
}

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

知道问题出在哪里吗?

解决方案是让 windows 更新执行其操作并更新 clr 版本。