如何动态切换网络服务地址在.NET中没有重新编译? [英] How can I dynamically switch web service addresses in .NET without a recompile?

查看:107
本文介绍了如何动态切换网络服务地址在.NET中没有重新编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有code引用一个Web服务,我想这Web服务的地址是动态的(从数据库,配置文件,阅读等),因此它很容易改变。一个主要用途的,这将是部署到多环境中的机器名和IP地址是不同的。 Web服务签名将在所有部署一样,只是在别处。

I have code that references a web service, and I'd like the address of that web service to be dynamic (read from a database, config file, etc.) so that it is easily changed. One major use of this will be to deploy to multiple environments where machine names and IP addresses are different. The web service signature will be the same across all deployments, just located elsewhere.

也许我只是被在Visual Studio宠坏添加Web引用向导 - 看起来这应该是比较容易的,但

Maybe I've just been spoiled by the Visual Studio "Add Web Reference" wizard - seems like this should be something relatively easy, though.

推荐答案

当您生成一个Web引用,然后单击在Solution Explorer Web引用。在属性窗格中,您应该看到这样的事情:

When you generate a web reference and click on the web reference in the Solution Explorer. In the properties pane you should see something like this:

更改值来动态将会把一个条目在你的app.config。

Changing the value to dynamic will put an entry in your app.config.

下面是一个有更多的信息, codePLEX文章

Here is the CodePlex article that has more information.

这篇关于如何动态切换网络服务地址在.NET中没有重新编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆