How can I dynamically switch web service addresses in .NET without a recompile?

后端 未结 11 972
小蘑菇
小蘑菇 2020-11-28 09:11

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

11条回答
  •  臣服心动
    2020-11-28 09:47

    If you are truly dynamically setting this, you should set the .Url field of instance of the proxy class you are calling.

    Setting the value in the .config file from within your program:

    1. Is a mess;

    2. Might not be read until the next application start.

    If it is only something that needs to be done once per installation, I'd agree with the other posters and use the .config file and the dynamic setting.

提交回复
热议问题