Cannot get Web API to work in VS 2010 or 2012

I have a machine with RC VS 2012 and VS2010 running on it. I am trying to execute the http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api code to try out the web API. I tried several different links on the Internet on how to fix problems, but still cannot get the Web API to work with IIS Express / Cassini for the host in my Windows 7 x64 window. I am currently getting "Method not found:" Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute (Boolean). " when trying to see what the list of products should be.

I followed the web page exactly as it was written, and did not add anything manually. I installed the night repository for the web stack http://www.myget.org/F/aspnetwebstacknightly/ , but I don’t know if this caused the problem. Here's the NuGet Get-Package dump in the program, if that helps.

PM> Get-Package Id Version Description/Release Notes -- ------- ------------------------- EntityFramework 5.0.0-rc Entity Framework is Microsoft recommended data access technology for new applications. jQuery 1.6.2 jQuery is a new kind of JavaScript Library.... jQuery.UI.Combined 1.8.11 jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built accordin... jQuery.Validation 1.8.1 This jQuery plugin makes simple clientside form validation trivial, while offering lots of option for customization. That makes a good choice if you're building something new from scratch, but also when y... knockoutjs 2.0.0 A JavaScript MVVM library to help you create rich, dynamic user interfaces with clean maintainable code Microsoft.AspNet.Mvc 4.0.20505.0 This package contains the runtime assemblies for ASP.NET MVC. ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you ... Microsoft.AspNet.Providers.... 1.0 ASP.NET Universal Providers add provider support in ASP.NET 4 for all editions of SQL Server 2005 and later and to SQL Azure. If you use these providers to develop your application, the application will b... Microsoft.AspNet.Providers.... 1.0 ASP.NET Universal Providers add provider support in ASP.NET 4 for all editions of SQL Server 2005 and later and to SQL Azure. If you use these providers to develop your application, the application will b... Microsoft.AspNet.Razor 2.0.20505.0 This package contains the runtime assemblies for ASP.NET Web Pages. ASP.NET Web Pages and the new Razor syntax provide a fast, terse, clean and lightweight way to combine server code with HTML to create d... Microsoft.AspNet.Web.Optimi... 1.0.0-beta2 ASP.NET Optimization introduces a way to bundle and optimize css/js files. Microsoft.AspNet.WebApi 4.0.20505.0 This package contains everything you need to host ASP.NET Web API on IIS. ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers a... Microsoft.AspNet.WebApi.Client 4.0.20505.0 This package adds support for formatting and content negotiation to System.Net.Http. It includes support for JSON, XML, and form URL encoded data. Microsoft.AspNet.WebApi.Core 4.0.20505.0 This package contains the core runtime assemblies for ASP.NET Web API. This package is used by hosts of the ASP.NET Web API runtime. To host a Web API in IIS use the Microsoft.AspNet.WebApi.WebHost packag... Microsoft.AspNet.WebApi.Web... 4.0.20505.0 This package contains everything you need to host ASP.NET Web API on IIS. ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers a... Microsoft.AspNet.WebPages 2.0.20505.0 This package contains core runtime assemblies shared between ASP.NET MVC and ASP.NET Web Pages. Microsoft.jQuery.Unobtrusiv... 2.0.20505.0 jQuery plugin that lets you unobtrusively set up jQuery Ajax. Microsoft.jQuery.Unobtrusiv... 2.0.20505.0 jQuery plugin that unobtrusively sets up jQuery.Validation. Microsoft.Net.Http 2.0.20505.0 This package provides a programming interface for modern HTTP applications. This package includes HttpClient for sending requests over HTTP, as well as HttpRequestMessage and HttpResponseMessage for proce... Microsoft.Web.Infrastructure 1.0.0.0 This package contains the Microsoft.Web.Infrastructure assembly that lets you dynamically register HTTP modules at run time. Modernizr 2.0.6 Modernizr adds classes to the <html> element which allow you to target specific browser functionality in your stylesheet. You don't actually need to write any Javascript to use it.... Newtonsoft.Json 4.5.1 Json.NET is a popular high-performance JSON framework for .NET WebGrease 1.0.0 Web Grease is a suite of tools for optimizing javascript, css files and images. 
+5
source share
3 answers

I turned on "Include Prerelease" for NuGet and updated all the packages to the latest nightly version. This fixed the problem in VS 2012. However, I do not know about VS2010.

+1
source

Actually, yes. The problem in this case is related to the packages, namely the package http://json.codeplex.com/ (Newtonsoft.Json.dll), which is used by the system. Web.Http.WebHost.dll.

Locally, I installed MVC 4 a few months ago (before the summer), but on my hosting server - much later. So, when I worked on the spot, everything worked fine ... and it even worked fine on the server, because I was just updating the binaries from svn. However, recently I needed to debug some things on the server, and “The method was not found:“ Void Newtonsoft.Json.Serialization. ”The problem arose. So, after some short research, I found the above cause of the problem.

But everything worked for me even with the 4 (not 4.5) version of the .NET Framework. So, I will need to install 4.5 on my server only for a small project that does not use any functions? !! So, I just replaced C: \ Program Files (x86) \ Microsoft ASP.NET \ ASP.NET MVC 4 \ Assemblies \ System.Web.Http.WebHost.dll from my local PC for easy compilation. In this case, I did not upgrade either .NET to 4.5 or json. But if you have 4.5 installed, you just need to update Newtonsoft.Json.dll.

In any case, this is a very strange error message in the age of "modern technologies" and such a great progress in the development of .NET (this is more likely reminiscent of some linker messages from the c / C ++ world). This is probably about the meaning of free (and open) software, when developers do not have enough time (or even will) to support such functions.

+1
source

I am using VS 2010 and I updated the latest version of Json.NET and the problem is resolved.

0
source

All Articles