开发者

Silverlight Domain Service Help

I have created a Silverlight Business app, and have created a Domain Service within the app.web project.

I 开发者_如何学Pythonhave created a method inside the DomainService class:

public String reHi()
    {
        return "HI";
    }

Inside my client, Silverlight page I had set the namepsace

using System.ServiceModel.DomainServices.Client;

I then included the following code to get the context:

Repas.Web.RepasContext t = new Repas.Web.RepasContext();
MessageBox.Show(t.reHi());

The project then fails to build with the error:

Error 2 Argument 1: cannot convert from 'System.ServiceModel.DomainServices.Client.InvokeOperation' to 'string'

I then added a toString to the code to see what it will output but I get:

System.ServiceModel.DomainServices.Client.InvokeOperation`1[System.String]

Can someone help me to get the output ("Hi") that I need.

Thanks.


All service calls to Silverlight are asynchronous; in other words, you don't get the response back immediately. Rather, you must set up an event handler for the completion of the call. I don't know your service definition, but it may look something like this:

var operation = t.reHi();
operation.Completed += (s, e) => {
    MessageBox.Show(operation.Value);
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜