c# - 无法加载文件或程序集 'Microsoft.IdentityModel.Clients.ActiveDirectory'

标签 c# .net nuget asp.net-identity

以下是我在运行 .NET 应用程序时遇到的确切异常。

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Generic.Helpers.dll

Additional information: Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.28.1.741, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

我有一个引用私有(private)程序集 (.dll) 的控制台应用程序。该程序集引用了 Microsoft.IdentityModel.Clients.ActiveDirectory,我还在项目中为此添加了一个 NuGet 包

<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.28.1" targetFramework="net46" />

我可以看到项目中正确引用了 DLL。但是,在运行应用程序时,出现上述错误。

只是为了给你一个类库项目的简要概述——这个 DLL 有连接到 CRM web api 的方法。直到最近几天,它都运行良好,突然停止工作并抛出错误。

我还在 Azure 函数中使用了相同的 DLL,这是它工作得很好的地方。

谁能建议如何解决这个问题?

最佳答案

可能是您没有那个特定版本?您是否尝试过在属性中将特定版本设置为 false?

NuGet 不会处理程序中的引用。它只是管理包。这个问题与 Visual Studio 有关。如果 NuGet 更新了一些包并且你的程序要求特定版本,你肯定会遇到问题。

关于c# - 无法加载文件或程序集 'Microsoft.IdentityModel.Clients.ActiveDirectory',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40799580/

相关文章:

c# - Convert.ChangeType 并转换为枚举?

.net - 如何提高DataGridView的绘画性能?

visual-studio - 将 nuget 包中的内容文件设置为 "copy local : always"

c# - 使用 JSON.NET 将动态 JSON 字符串解析为 C# 中的字符串

c# - 创建连接字符串并使用 SQL Server LocalDB

c# - 在 Visual Studio 中重构 .asmx 文件

.net - 使用 HttpListener 时如何确保 http 请求是本地的

.net - 如何识别延迟签名程序集

git - Azure Web App (linux) dotnet core 2.2 中默认部署脚本的权限问题

nuget - 在 Linqpad 中更改 nuget 包位置