【问题标题】:Is it possible to generate WCF async service contracts for Silverlight on runtime?是否可以在运行时为 Silverlight 生成 WCF 异步服务合同?
【发布时间】:2010-09-02 08:30:37
【问题描述】:

我有一个 WCF 服务合同,内容如下:

    [ServiceContract(Name = "DummyService") ]
    public interface IDummyService {

        [OperationContract]
        void DoSomething();

        [OperationContract(Name = "SayHello")]
        string SayHello(string message);
    }

WCF 服务将由 Silverlight 应用程序使用。我正在寻找一种方法来消除手动编写异步合同的需要,这样我就可以通过 ChannelFactory 生成的代理来使用它。

我正在考虑编写一个专门的调用程序类。示例用法如下:

// create the invoker using the endpoint config and the existing sync contract
var client = new ServiceInvoker<IDummyService>("LeyDummyService_Endpoint");

// invoke the desired service method set the callback, very similar to how 
// JQuery does AJAX calls...
client.Invoke(dummyService => dummyService.SayHello("harley"),
             (result) => MessageBox.Show(result));

有人试过吗?这甚至可能吗?

【问题讨论】:

    标签: silverlight wcf


    【解决方案1】:

    您是否尝试过使用Svcutil?它会为你编写所有的异步合约。

    【讨论】:

    • 不是一个选项。我讨厌为那些异步合约编写代码,因此问题
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      相关资源
      最近更新 更多