未找到方法“太虚Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(布尔) [英] Method not found 'Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)

查看:375
本文介绍了未找到方法“太虚Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(布尔)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了一个的WebAPI示例代码和我得到这个例外
我使用Visual Studio 2012终极版开通此示例,我有,当我运行此应用程序newtonsoft installed.I的最新优化版本正在此错误。它成功地进行编译。
知道为什么这个错误,是有解决这个异常的方式。

  system.missingMethodException而被用户未处理代码
HResult的= -2146233069
消息=未找到方法:'太虚Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(布尔)。
来源= System.Net.Http.Formatting
堆栈跟踪:在System.Net.Http.Formatting.JsonContractResolver..ctor
(MediaTypeFormatter格式)
在System.Net.Http .Formatting.JsonMediaTypeFormatter..ctor()在System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters
()
在System.Net.Http.Formatting.MediaTypeFormatterCollection..ctor()
在System.Web.Http.HttpConfiguration.DefaultFormatters()在System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection路由)
。在System.Web.Http.GlobalConfiguration
< .cctor> b__0 ()在System.Lazy`1.CreateValue()
在System.Lazy`1.LazyInitValue()
在System.Lazy`1.get_Value()
。在系统
在System.Web.Http.RouteCollectionExtensions.MapHttpRoute .Web.Http.GlobalConfiguration.get_Configuration()
(RouteCollection路线,字符串名称,字符串routeTemplate,默认对象,对象的限制,HttpMessageHandler处理)
的系统。 Web.Http.RouteCollectionExtensions.MapHttpRoute(RouteCollection路线,字符串名称,字符串routeTemplate,对象默认值),在在C WebAPIRc.RouteConfig.RegisterRoutes(RouteCollection路线)
:\Users\viemon\Downloads\WebAPIRc\\ \\WebAPIRc\WebAPIRc\App_Start\RouteConfig.cs:在WebAPIRc.WebApiApplication.Application_Start(c)中第17行
:\Users\viemon\Downloads\WebAPIRc\WebAPIRc\WebAPIRc\\ \\Global.asax.cs:行36
的InnerException:

下面是代码的地方失败

 公共类RouteConfig 
{
公共静态无效的RegisterRoutes(RouteCollection路线)
{
routes.IgnoreRoute({}资源个.axd / {*} PATHINFO);
//异常错误启动
routes.MapHttpRoute(
的名字:DefaultApi,
routeTemplate:API / {}控制器/(编号),
默认新{ID = RouteParameter.Optional}
);
//异常错误结束

routes.MapRoute(
产品名称:默认,
网址:{控制器} / {行动} / {ID} ,
默认设置:新{控制器=家,行动=索引,ID = UrlParameter.Optional}
);
}
}



我才知道,我需要打开包括抢鲜为的NuGet 从这个帖子
,但我怎么打开如何打开包含预发行为的NuGet?


解决方案

我怎么打开如何打开包含预发行为的NuGet?




要安装的Json .NET是包含预发行,运行的程序包管理器控制台

 安装封装Newtonsoft.Json -IncludePrerelease 


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:\Users\viemon\Downloads\WebAPIRc\WebAPIRc\WebAPIRc\App_Start\RouteConfig.cs:line 17
       at WebAPIRc.WebApiApplication.Application_Start() in c:\Users\viemon\Downloads\WebAPIRc\WebAPIRc\WebAPIRc\Global.asax.cs:line 36
  InnerException: 

Here is the code where it fails

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 }
            );
        }
    }

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 ?

解决方案

how do I turn on how to turn on the "Include Prerelease" for NuGet ?

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(布尔)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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