WPF部署(一):WebService配置文件及编译时拷贝

来源:互联网 发布:网络真人赌博骗局 编辑:程序博客网 时间:2024/05/16 14:39

1.webservice配置文件读取
本项目是添加的兼容.net 2.0 WebService:
a.References->Advanced->Add Web Reference
b.在URL栏里面加上地址:http://10.185.XXX.XXX:XXXX/XXX/GetMainXXX?wsdl
c.向导生成的Reference.cs文件中,Service构造函数里面添加代码:
<span style="font-size:18px;">  if (GlobalSceneFuns.getInstance().isEntryPointConfig)//增加代码:读取App.config的配置                this.Url = ConfigurationManager.AppSettings["DataCenterService"];            else//向导添加的代码,默认            this.Url = xxxx;//URLAddress</span>

d.App.config配置
<appSettings>
<!--描述-->
<add key="DataCenterService" value="http://10.185.XXX.XXX:XXXX/XXX/GetMainXXX/" />
</appSettings>
这样,程序WebService部署地址修改时,只需要修改App.config配置


2. 编译时拷贝
部署时,将需要发布的文件属性设置为Copy always,这样编译时会将文件拷贝到生成目录。


0 0
原创粉丝点击