且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么加入我的Web API的依赖(ASP.NET V5)项目没有完全工作?

更新时间:2023-01-26 07:59:46

当你构建,检查出的项目列 - 它指出,发生故障的版本是ASP.NET 5.0的核心(而不是ASP。 NET 5.0)。在code编辑器的左上角下拉菜单中,您可以选择不同的观点 - 如果你选择ASP.NET 5.0核心之一,你会看到NodaTime命名空间是不确定的。

When you build, check out the "Project" column - it notes that the build that is failing is "ASP.NET Core 5.0" (not "ASP.NET 5.0"). In the upper left dropdown of the code editor, you can choose different views - if you select the "ASP.NET Core 5.0" one, you'll see that the NodaTime namespace is undefined.

它看起来像新的ASP.NET项目模板创建多靶点的应用程序,无论是aspnet50和aspnetcore50。

It looks like the new ASP.NET project templates are creating multi-targeted apps, both aspnet50 and aspnetcore50.

ASP.NET 5.0是(目前)基于.NET 4.5.x,所以NodaTime便携式(NET4)满足该平台。 ASP.NET 5.0的核心是基于新的CoreClr(aspnetcore50),并且有在NodaTime库中没有二进制文件支持它。

ASP.NET 5.0 is (currently) based on .NET 4.5.x, so the NodaTime portable (net4) satisfies that platform. ASP.NET Core 5.0 is based on the new CoreClr (aspnetcore50), and there's no binaries in the NodaTime library that support it.

要解决,你可以仅仅通过在框架中删除的project.jsonaspnetcore50条目放弃对CoreClr支持您的应用程序

To resolve, you can just drop support for CoreClr in your application by removing the "aspnetcore50" entry in project.json under "frameworks":

"frameworks": {
    "aspnet50": { }
    //"aspnetcore50": { }
},

现在您的应用程序应该建立目标只是ASP.NET 5.0,而不是CoreClr。

Now your app should build just targeting ASP.NET 5.0 and not the CoreClr.