类型'System.Threading.Tasks.Task`1 [System.String]'不能被序列化 [英] Type 'System.Threading.Tasks.Task`1[System.String]' cannot be serialized

查看:2420
本文介绍了类型'System.Threading.Tasks.Task`1 [System.String]'不能被序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照下面的文章中,我定义我的服务合同。

As per the following article, I have defined my service contract as

<一个href=\"http://blogs.msdn.com/b/endpoint/archive/2010/11/13/simplified-asynchronous-programming-model-in-wcf-with-async-await.aspx\" rel=\"nofollow\">http://blogs.msdn.com/b/endpoint/archive/2010/11/13/simplified-asynchronous-programming-model-in-wcf-with-async-await.aspx

[ServiceContract]
public interface IServiceContract
{
    [OperationContract]
    Task<string> HelloAsync(string name);
}

然而,当我尝试生成一个代理,我得到的消息类型'System.Threading.Tasks.Task`1 [System.String]'不能被序列化。

However, when I try to generate a proxy, I get the message Type 'System.Threading.Tasks.Task`1[System.String]' cannot be serialized.

我失去了一些东西在这里?

Am I missing something here?

推荐答案

针对基于任务的异步操作的支持仅在.NET Framework的4.5版本,除非您使用的开发商preVIEW这是在九月中旬可用,这是不行的。

The support for Task-based asynchronous operations is only available in the version 4.5 of the .NET Framework Unless you're using the developer preview which was made available in mid-September, this won't work.

这篇关于类型'System.Threading.Tasks.Task`1 [System.String]'不能被序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆