Method not found #39;Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)(找不到方法无效 Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean))
问题描述
我下载了 webapi 的示例代码,我得到了这个异常我使用 Visual Studio 2012 Ultimate Version 打开了这个示例,并且我安装了最新版本的 newtonsoft.运行此应用程序时出现此错误.编译成功.知道为什么会出现这个错误,有没有办法解决这个异常.
I downloaded a sample code for webapi and I am getting this exception I opened this sample using Visual Studio 2012 Ultimate Version and I have latest verion of newtonsoft installed.I am getting this error when I run this application.Its compiling successfully. Any idea why this error and is there a way to resolve this exception.
System.MissingMethodException was unhandled by user code
HResult=-2146233069
Message=Method not found: 'Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)'.
Source=System.Net.Http.Formatting
StackTrace:
at System.Net.Http.Formatting.JsonContractResolver..ctor(MediaTypeFormatter formatter)
at System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor()
at System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters()
at System.Net.Http.Formatting.MediaTypeFormatterCollection..ctor()
at System.Web.Http.HttpConfiguration.DefaultFormatters()
at System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes)
at System.Web.Http.GlobalConfiguration.<.cctor>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at System.Web.Http.GlobalConfiguration.get_Configuration()
at System.Web.Http.RouteCollectionExtensions.MapHttpRoute(RouteCollection routes, String name, String routeTemplate, Object defaults, Object constraints, HttpMessageHandler handler)
at System.Web.Http.RouteCollectionExtensions.MapHttpRoute(RouteCollection routes, String name, String routeTemplate, Object defaults)
at WebAPIRc.RouteConfig.RegisterRoutes(RouteCollection routes) in c:UsersviemonDownloadsWebAPIRcWebAPIRcWebAPIRcApp_StartRouteConfig.cs:line 17
at WebAPIRc.WebApiApplication.Application_Start() in c:UsersviemonDownloadsWebAPIRcWebAPIRcWebAPIRcGlobal.asax.cs:line 36
InnerException:
这是失败的代码
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//Exception error start
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
//exception error end
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
我知道我需要为 NuGet 打开包含预发布"来自这篇文章,但是如何开启如何开启 NuGet 的Include Prerelease"?
I came to know that I need to turn on "Include prerelease" for NuGet from this post, but how do I turn on how to turn on the "Include Prerelease" for NuGet ?
推荐答案
如何开启如何开启 NuGet 的包括预发布"?
how do I turn on how to turn on the "Include Prerelease" for NuGet ?
要使用包含预发行版" 安装 Json.NET,请在 包管理器控制台
To install Json.NET with "Include Prerelease", run the following command in the Package Manager Console
Install-Package Newtonsoft.Json –IncludePrerelease
这篇关于找不到方法'无效 Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:找不到方法'无效 Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)
基础教程推荐
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
