专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > WCF

WCF开发札记 高版本.Net的坑

发布时间:2011-06-23 13:51:12 文章来源:www.iduyao.cn 采编人员:星星草
WCF开发笔记 高版本.Net的坑

高版本.Net的坑

开发环境

.Net 4.5.1
Visual Studio 2015RC
Windows 8.1
SQL Server 2005 sp1

运行环境

.Net 4.0 en
Windows Server 2003
SQL Server 2005 sp1

现象

 

WCF客户端,开发环境测试正常。发布到运行环境后,提示Type 'System.Threading.Tasks.Task`1[XMRBI.ERoad.Contracts.ServiceResponse]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types.

原因

Visual Studio 2012以上版本的svcutil默认情况下会生成XXXAsync的调用方法。类似System.Threading.Tasks.Task<T>。但是在运行环境,.Net4.0不支持Task<T>

解决方案

  1. 关闭生成异步方法

    1. svcutil /syncOnly
  2. 手动删除生成结果的XXXAsync方法



来自为知笔记(Wiz)



友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: