以下是我在运行 .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/