WebGetAttribute我应该参考什么

时间:2012-02-18 23:19:34

标签: json wcf .net-4.0 webget

我正在.NET 4.0中构建WCF WindowsService。我想将它变成RESTfull并将响应和请求类型更改为JSON。为此,我需要在界面中使用OperationContract下的WebGetAttribute。但我找不到System.ServiceModel.Web程序集(根据MSDN,它应该在System.ServiceModel.Web.dll中)。在“添加引用”表单中没有该DLL的痕迹,如果我尝试“使用System.ServiceModel.Web;”,它也无法正常工作。

你知道我的问题是什么吗?

2 个答案:

答案 0 :(得分:1)

好吧,事实证明我的目标是“.NET Framework 4 Client Profile”,它不会公开所有的DLL。感谢this post。将其更改为“.NET Framework 4”,一切正常。

答案 1 :(得分:1)

从.NET Framework 4开始,您根本不再需要引用System.ServiceModel.Web.dll。该文章已过时,从.NET Framework 4开始,System.ServiceModel.Web.dll中的所有类只是转发到System.Runtime.Serialization.dll和System.ServiceModel.dll中的类。

所以,我的观点是 - 只要您不使用.NET Framework的客户端配置文件 - 只需参考System.Runtime.Serialization.dll和System.ServiceModel.dll,就应该设置