引用类库ASP.NET中的5 - 依赖问题 [英] Referencing class library in ASP.NET 5 - dependency issues

查看:252
本文介绍了引用类库ASP.NET中的5 - 依赖问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的自定义的类库(.NET目标4.5.1)引用Newtonsoft.Json 8.0.2(最新版本为准)。我已经添加了这个类库作为一个新的ASP.NET网页5 API项目的引用。

My custom class library (targeting .NET 4.5.1) references Newtonsoft.Json 8.0.2 (the latest version to date). I've added this class library as a reference to a new ASP.NET 5 Web API project.

错误列表的输出:

错误NU1002项目MyProject的依存Newtonsoft.Json 1.0.0不支持框架DNXCore,版本V5.0 =

这部分似乎有点不言自明的,但是,我不明白为什么它改变了我的参考版本的 1.0.0。

That part seems somewhat self-explanatory, however, I couldn't understand why it was changing my referenced version to 1.0.0.

参考 - > DNX 4.5.1 - > MyClassLibrary 的节点:

NU1007依赖指定被Newtonsoft.Json> = 8.0.2,但结束了Newtonsoft.Json 1.0.0。

我试着删除/重新添加引用了几次,都没有用。我也注意到,有几个ASP.NET库的使用Newtonsoft.Json 6.0.6 - 我不知道这有什么关系呢

I've tried removing/re-adding the references several times, all to no avail. I did notice that several of the ASP.NET libraries use Newtonsoft.Json 6.0.6 -- I'm not sure if this has anything to do with it.

如果我浏览到的文件夹裹 - > Newtonsoft.Json - > JSON文件的,和替换的Newtonsoft.Json 1.0.0 - *的有Newtonsoft.Json 8.0.2 - *的,它修复了4.5.1 DNX节点引用。

If I navigate to the wrap folder --> Newtonsoft.Json --> json file, and replace "Newtonsoft.Json 1.0.0-*" with "Newtonsoft.Json 8.0.2-*", it fixes the references for the DNX 4.5.1 node.

然而,错误仍然显示事后说Newtonsoft.Json 8.0.2在我的类库引用不支持DNXCore 50。

However, errors still show afterwards saying that Newtonsoft.Json 8.0.2 referenced in my class library does not support DNXCore 50.

我在茫然,怎么做。任何帮助将大大AP preciated。

I'm at a loss as to what to do. Any help would be greatly appreciated.

推荐答案

回答我的问题:
由于奥列格的反应我就能够使它发挥作用 - 但有两个障碍。一个是被用于Newtonsoft.Json创建的包​​的文件夹。在我的解决方案的根源是包含一个名为Newtonsoft.Json文件夹中的包的文件夹。显然,(?),该文件夹不应该已创建(它是如何创建我不知道)。一旦去除,我可以添加一个引用到我的自定义类的库而不引用Newtonsoft.Json任何错误。

Answer to my issue: Thanks to Oleg's response I was able to make it work -- however there were two hurdles. One was the "wrap" folder that was created for Newtonsoft.Json. In the root of my solution was a "wrap" folder that contained a folder called Newtonsoft.Json. Apparently(?) that folder shouldn't have been created (how it was created I have no idea). Once removing that, I was able to add a reference to my custom class library without any errors referencing Newtonsoft.Json.

然而,当我开始尝试使用我的自定义组件,比如code,我会得到大约DNX50错误不被支持的 - 这sort've是有道理的,因为我的自定义引用的程序集是.NET 4.5.1类库。

However when I began trying to use my custom assembly as in code, I would get an error about DNX50 not being supported -- which sort've makes sense because my custom referenced assembly was a .NET 4.5.1 class library.

这GitHub的链接有很多人遇到类似的问题

不过,我设法得到的一切建设和错误通过消除针对DNXCore50去了。这为我工作,因为我只是想一个Web API和WPF项目之间共享一些POCO数据模型。我不感兴趣,目前针对DNXCore。

However, I managed to get everything to build and errors to go away by removing targeting for DNXCore50. This worked for me because I was just wanting to share some POCO data models between a Web API and WPF project. I'm not interested in targeting DNXCore at the moment.

我很期待ASP.NET的未来,但新旧是一个挑战,至少对我来说。

I'm looking forward to the future of ASP.NET, but the newness is a bit challenging, at least for me.

这篇关于引用类库ASP.NET中的5 - 依赖问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆