在 System.Type 上创建动态代理
我有 List
,这里 Type 是我使用反射获得的接口。 那么如何在这些类型上使用通道工厂创建 wcf 代理。
就像:
foreach(Type t in types)
{
t proxy = ChannelFactory<t>.CreateChannel(new NetTcpBinding(),
new EndpointAddress(serviceAddress));
}
这里 t 是接口,但上面的代码给出了编译器错误。任何人都可以告诉我如何在类型上创建 wcf 服务代理。
I have List<Type>
, here Type is interface which i got using reflection.
So how to create the wcf proxy using channnel factory on these Type.
like:
foreach(Type t in types)
{
t proxy = ChannelFactory<t>.CreateChannel(new NetTcpBinding(),
new EndpointAddress(serviceAddress));
}
Here t is interface but the above code is giving compiler error.Can anybody tell me how to create wcf service proxy on Type.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用反射并调用方法
Type.MakeGenericType
:You can use reflection and call the method
Type.MakeGenericType
: