添加 Class 库程序集后出现 FileNotFoundException

FileNotFoundException when after adding a Class Library assembly

我有一个 ASP.NET MVC Core 应用程序,想在我的项目中添加一个 Class 库。 我通过 "Add Reference" > "Browse" > select DLL 在我的项目中添加了它并完成了。

我把它添加到像

这样的代码中
using PagarMe; // works good on code 

而且我能够编译 运行 应用程序。然而,当用户转到引用 lib 的页面时,我得到了休闲错误。:

FileNotFoundException: Could not load file or assembly 'PagarMe.Pcl, Version=2.0.6372.16631, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

我已经做了什么。

我该怎么做才能在我的核心应用程序中使用 Class 库或 PCL 库?

在 .NET Core 中,您不再使用可移植 Class 库,但您的目标是 .NET Standard Library 的正确版本。一些 PCL 或 Shared Classes 可能使用一些不受支持的 参考。

要解决此问题,请尝试以下方法之一:

1.重建您的 Class 库以面向 .NET Standard。例如,.NET Standard 1.6 受 .NET Core 1.0 和 .NET Framework 4.6.1 支持。

.NET Standard can be thought of as the next generation of Portable Class Libraries (PCL). The .NET Standard improves on the experience of creating portable libraries by curating a standard BCL and establishing greater uniformity across .NET runtimes as a result. A library that targets .NET Standard is a PCL or a ".NET Standard-based PCL". Existing PCLs are "profile-based PCLs". (Taken from the documentation)

2。将您的应用定位到 .NET Framework。 您可以构建一个 ASP.NET Core 应用程序来针对完整的 .NET Framework 而不是仅针对 .NET Core。这为您提供了 ASP.NET Core 的优势,而没有 .NET Core 的限制。

ASP.NET 核心 != .NET 核心