Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
914 views
in Technique[技术] by (71.8m points)

c# - Method not found 'Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)

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: 

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...