5

我有一台运行 VS 2012 和 VS2010 RC 的机器。我正在尝试按照http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api上的代码试用 Web API . 我尝试在网上关注一些关于如何解决问题的不同链接,但仍然无法让 Web API 使用 IIS Express/Cassini 为我的 Windows 7 x64 机器上的主机工作。目前我收到“找不到方法:'Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)'。” 尝试查看应该是什么产品列表时出错。

我完全按照网页的内容进行操作,没有手动添加任何内容。我确实为网络堆栈http://www.myget.org/F/aspnetwebstacknightly/设置了夜间存储库,但不知道这是否导致了问题。如果有帮助,这里是程序上 NuGet 的 Get-Package 的转储。

PM> Get-Package

Id                             Version              Description/Release Notes                                                                                                                                                                                      
--                             -------              -------------------------                                                                                                                                                                                      
EntityFramework                5.0.0-rc             Entity Framework is Microsoft's 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.                                                                                                                                
4

3 回答 3

1

我打开了 NuGet 的“包含预发布”,并将所有包更新为最新的夜间版本。它解决了 VS 2012 中的问题。虽然不知道 VS2010。

于 2012-07-27T15:46:29.927 回答
1

其实,是。这种情况下的问题与包有关,即System.Web.Http.WebHost.dll 使用的http://json.codeplex.com/ (Newtonsoft.Json.dll) 包。

几个月前(夏天之前),我在本地安装了 MVC 4,但在我的托管服务器上 - 更晚了。所以,当我在本地工作时,一切都运行良好......甚至在服务器上运行良好,因为我只是从 svn 更新二进制文件。但是,最近我需要在服务器上调试一些东西并且“找不到方法:'Void Newtonsoft.Json.Serialization”。问题出现了。因此,经过一些简短的探索,我发现了上述问题的原因。

但即使使用 4(不是 4.5).NET Framework 版本,一切都对我有用。那么,我是否必须在我的服务器上安装 4.5 只是为了一些不使用它的功能的小项目?!!因此,我刚刚从本地 PC 替换了 C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Http.WebHost.dll 以便于编译。在那种情况下,我既没有将 .NET 更新到 4.5,也没有更新 json。但是如果你安装了 4.5,你只需要更新 Newtonsoft.Json.dll。

无论如何,这在“现代技术”世纪和 .NET 开发的巨大进步中确实是非常奇怪的错误消息(它宁愿提醒一些来自 c/c++ 世界的链接器消息)。可能,这完全是关于免费(和开源)软件的感觉,当开发人员没有太多时间(甚至没有时间)来支持这些功能时。

于 2012-12-08T17:57:48.427 回答
0

我使用VS 2010,我更新了最新版本的Json.NET,问题解决了

于 2013-04-26T07:21:55.863 回答