Take the 2-minute tour ×

I'm trying to implement the following into my silverlight wcf ria services project.


It is working fine for entities. However I'm trying to write a custom method that returns a string and throws an error.

Custom method

    public string GetHello(string str)
        return ("Hello " + str);

Calling from Client

String str;

str = await context.LoadAsync(context.GetHello("Sam")).ToString();


The 'await' operator requires that its operand 'System.ServiceModel.DomainServices.Client.InvokeOperation' have a suitable public GetAwaiter method

share|improve this question
Please double-check your example code. Are you absolutely sure that this client code will result in that error? –  Stephen Cleary Sep 29 '11 at 4:07
add comment

1 Answer

You need to call AsTask to convert the InvokeOperation to a Task.

share|improve this answer
I tried that and now I get Cannot implicitly convert type 'System.ServiceModel.DomainServices.Client.InvokeOperation<string>' to 'string' hstring = await this.parentWindow.ctx.HashString("asdasd").AsTask(); This method works fine if I call it asynchronously(using a delegate). But I'm using async CTP and Kyle's code to call the method synchronously. –  Paul Krish Sep 29 '11 at 16:19
After you await it, then read the InvokeOperation<string>.Value member. e.g., (await this.parentWindow.ctx.HashString("asdasd").AsTask()).Value –  Stephen Cleary Sep 29 '11 at 17:13
I couldn't find AskTask(). Where is it defined? –  Chui Tey Apr 6 '12 at 10:07
It's in the blog post you referenced in your question. –  Stephen Cleary Apr 6 '12 at 14:46
add comment

Your Answer


