【发布时间】:2012-01-29 20:16:24
【问题描述】:
我在为通过 HTTP 公开的简单 WCF 服务实现 MonoTouch 客户端时收到以下 InvalidOperationException。
MonoTouch 不支持动态代理代码生成。重写此方法或其调用者以返回特定的客户端代理实例。
来自this file 的第 141 行。
所以我需要在我自己的 ClientBase 子类中使用不使用动态代码生成的实现来覆盖 System.ServiceModel.ClientBase<T> 上的方法 CreateChannel()。该方法返回一个T 的实例。
如果我返回服务客户端的新实例,System.ServiceModel.ClientBase<T> 会在 InnerChannel 的 getter 上抛出异常 Unable to cast object of type 'MyServiceClient' to type 'System.ServiceModel.IClientChannel'。
我不知道如何从这一点开始 - 任何指针表示赞赏。
【问题讨论】:
标签: c# wcf xamarin.ios