首页 > 解决方案 > ASP.NET 错误:System.TypeLoadException 无法加载字段“Microsoft.Owin.Security.ActiveDirectory”的类型

问题描述

我从 git 存储库克隆了一个应用程序,该应用程序构建时没有错误和警告,但是当我运行该应用程序时,我收到以下错误:错误 500:System.TypeLoadException 无法加载字段类型“Microsoft.Owin.Security.ActiveDirectory”。 WsFedMetadataRetriever:CS$<>9__CachedAnonymousMethodDelegate5' (1) 由于:无法使用令牌 01000045 解析类型(来自 typeref、类/程序集 System.IdentityModel.Metadata.KeyDescriptor、System.IdentityModel、Version=4.0.0.0、Culture=neutral、 PublicKeyToken=b77a5c561934e089) 程序集:System.IdentityModel,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089 类型:System.IdentityModel.Metadata.KeyDescriptor 成员:(null) 签名:

我试图通过将以下内容添加到 web.config 文件来解决此问题:

 <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
    <dependentAssembly>

...但我仍然得到错误;我正在使用适用于 Mac 的 Visual Studio Community 2017。请问我能得到一些帮助吗?

标签: c#asp.net

解决方案


我更新了所有 Nuget 包,并安装了 Microsoft.ApplicationInsights.AspNetCore 它对我有用


推荐阅读