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

后端 未结 3 1127
伪装坚强ぢ
伪装坚强ぢ 2020-12-10 17:04

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 i

相关标签:
3条回答
  • 2020-12-10 17:22

    Another cause of this can be if you have an older version in your GAC. For me the version was in the .NET 4.0 GAC removing this resolved the issue

    0 讨论(0)
  • 2020-12-10 17:24

    In My Case You I just remove the following line in RouteConfig (it was already obliterated).

      //Exception error start
        routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
      //exception error end
    

    In VS2012, this should be enough.

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
    

    You may also need to verify your controller. Also remove some Class reference in RouteConfig, if you are not sure if what they were for. In My Case I just retain the these two:

    using System.Web.Mvc;
    using System.Web.Routing;
    

    Another solution is if you want and have a time to figure out what causes the conflict, then you may set your Project Build Output verbosity to Detailed (Go to Tools-> Options -> Project and Solutions -> Build and Run -> MSBuild project build output verbosity) and upon build check your logs.

    0 讨论(0)
  • 2020-12-10 17:26

    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
    
    0 讨论(0)
提交回复
热议问题