码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-08-09 01:42:01      阅读:405      评论:0      收藏:0      [点我收藏+]

标签:

高版本.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方法





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

标签:

原文地址:http://www.cnblogs.com/boywujch/p/1a92652ed40f8a6182339e6469b72028.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!