无法访问方法 Newtonsoft.JSON .Net Core 2.* [英] Cannot access methods Newtonsoft.JSON .Net Core 2.*

查看:37
本文介绍了无法访问方法 Newtonsoft.JSON .Net Core 2.*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个项目的解决方案,所有项目都使用 .Net Core 2.1 (VS 2017).我可以在我的 web 项目中使用 Newtonsoft.JSON.JsonConvert 来序列化和反序列化对象.

I'm have a solution with multiple projects all using .Net Core 2.1 (VS 2017). I can use Newtonsoft.JSON.JsonConvert in my web project without any problem for serializing and deserializing objects.

同一解决方案中的另一个项目与我的 Web 项目具有相同的 Nuget 包(版本和 SDK).Intellisense 识别 JsonConverter,但唯一显示的方法是 Equals,因此没有 SerializeObject 或 DeserializeObject.

Another project in the same solution has the same Nuget packages (version and SDK) as my web project. Intellisense recognizes JsonConverter, but the only method that shows is Equals, so no SerializeObject or DeserializeObject.

当我在控制台应用程序中打开 JsonConvert 定义时,它具有命名空间 Newtonsoft.Json 和一个公共抽象类 JsonConverter

When I open the JsonConvert Definition within my console application it has the namespace Newtonsoft.Json and a public abstract class JsonConverter

当我在 web 项目中做同样的事情时,我得到了命名空间 Newtonsoft.Json 和一个 公共静态类 JsonConvert

When I do the same within the web project I get the namespace Newtonsoft.Json and a public static class JsonConvert

最后一个包含我想使用的方法,但我不知道为什么会出现这个问题以及如何解决它.

The last one contains the methods I want to use, but I've no idea why this problem is occurring and how to solve it.

推荐答案

看起来我需要 JsonConvert 而不是 JsonConverter...

Looks like I needed JsonConvert instead of JsonConverter...

这篇关于无法访问方法 Newtonsoft.JSON .Net Core 2.*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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