【发布时间】:2018-12-15 09:33:46
【问题描述】:
在我的 Windows 服务中,我有 2 个网络参考
我的 windows 服务只包含一个 app.config 不是 web.config
我的应用配置如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyFirstWindowsService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<bindings />
<client />
</system.serviceModel>
<applicationSettings>
<MyFirstWindowsService.Properties.Settings>
<setting name="MyFirstWindowsService_postDataToMapicsWC_XAXSSTRN"
serializeAs="String">
<value>http://TESTDEV/web/services/XAXSSTRN.XAXSSTRNHttpSoap11Endpoint/</value>
</setting>
<setting name="MyFirstWindowsService_com_goodmanmfg_testdev_GETITMINFO"
serializeAs="String">
<value>http://TESTDEV/web/services/GETITMINFO.GETITMINFOHttpSoap11Endpoint/</value>
</setting>
</MyFirstWindowsService.Properties.Settings>
</applicationSettings>
</configuration>
[![在此处输入图片描述][1]][1]
问题是我的网络服务,当我点击它们时,URL 字段仍在显示
“网络参考网址”http://PROD/web/services/XAXSSTRN.XAXSSTRNHttpSoap11Endpoint [![在此处输入图片说明][2]][2]
最终目标是什么?将此 Windows 服务发布到开发和生产环境,而无需重新构建整个解决方案。
理想的行为是:
在开发模式下构建最新代码(测试它,如果所有测试都很好,则第 2 步)
提供一个带有 prod url 的 app.config 文件以放入 文件夹
-
发布
如您所见,我试图避免的是手动删除文件更改这 2 个 Web 服务、重建解决方案然后发布...
【问题讨论】:
-
我个人使用本地文本文件和我的 Web 服务的路径,并使用文本文件中的值手动对端点进行编码。很简单。您只需要添加一次网络参考,至少在您使用它时拥有智能。交换时,我在网络服务器上只有 2 台主机并更新了一台并交换了该路径上的每个人。下次我这样做时,我会更新另一个 web 文件夹并交换每个人的位置
标签: c# web-services windows-services app-config