Type 'System.Threading.Tasks.Task`1[System.Str

2019-02-16 03:19发布

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

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);
}

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?

2条回答
我想做一个坏孩纸
2楼-- · 2019-02-16 03:49

Here is a good answer: http://mylifeandcode.blogspot.com/2012/12/the-cause-and-solution-for.html

Seems need to re-generate proxy classes - instead of "Generate task-based operations" need to choose "Generate asynchronous operations".

查看更多
来,给爷笑一个
3楼-- · 2019-02-16 04:01

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.

查看更多
登录 后发表回答