简体   繁体   English

动态添加WCF服务参考

[英]Dynamically add reference of WCF service

I am creating a WCF service and Client application. 我正在创建WCF服务和客户端应用程序。 I want to use the service in the client application. 我想在客户端应用程序中使用该服务。

The location where the WCF service will be hosted is not yet finalized. WCF服务的托管位置尚未最终确定。 I want to dynamically add the reference of the hosted WCF service without building the client application. 我想动态添加托管WCF服务的引用,而无需构建客户端应用程序。 How can I achive this? 我该如何实现?

Thanks, 谢谢,

Ram 内存

Do this: 做这个:

  • create the client as you would in any normal case 像在任何正常情况下一样创建客户端
  • change the service URL in the config when the service "moves" around 当服务“移动”时,在配置中更改服务URL

I think this would be by far the easiest solution. 我认为这是迄今为止最简单的解决方案。

If you insist on a dynamic proxy - there's a sample of a WCF dynamic proxy here: 如果您坚持使用动态代理-这里有一个WCF动态代理示例:

http://code.msdn.microsoft.com/netfxsamples/Wiki/Print.aspx?title=WCF%20samples&version=8&action=Print http://code.msdn.microsoft.com/netfxsamples/Wiki/Print.aspx?title=WCF%20samples&version=8&action=Print

Scroll down a bit to find the sample. 向下滚动一点以找到示例。 It was C# code to show you how to dynamically create a WCF proxy all in code. 这是C#代码,向您展示如何在代码中动态创建WCF代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM