【问题标题】:App.config in WCF Library and its Windows Service HostWCF 库及其 Windows 服务主机中的 App.config
【发布时间】:2010-04-04 14:08:42
【问题描述】:

我有两个名为 TemplateService 的服务 TemplateReportService(均在一个 WCF 服务库中定义)要公开给客户端应用程序。

而且,我正在尝试在 Windows 服务下托管这些服务。

如果 Windows 服务中的 App.config 与 WCF 库中的相同,谁能指导我?

这是我在 WCF 库中的 app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>

  <system.serviceModel>     
    <services>
      <service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
        name="ReportingComponentLibrary.TemplateService">
        <endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateService" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateService/" />
          </baseAddresses>
        </host>
      </service>

      <service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
        name="ReportingComponentLibrary.TemplateReportService">
        <endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateReportService" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateReportService/" />
          </baseAddresses>
        </host>
      </service>

    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ReportingComponentLibrary.TemplateServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

所以,我的 Windows 服务中的 App.config(我在其中托管以上两个服务) 将与上面相同,或者我只需要移动一些特定的部分。

请指导。

谢谢!

【问题讨论】:

    标签: wcf service app-config


    【解决方案1】:

    首先,删除我们在您的其他问题中谈到的。第二个库没有自己的 .config 文件,并且没有(内置)方法可以在 .NET 中导入某些配置部分。因此,您必须将每个库的配置设置整合到 Windows 服务的单个 app.config 中。

    【讨论】:

    • 感谢您的回复。我做的错误是将 app.config 从 WCF 库复制到 Windows 服务安装文件夹。而我只需要在 Windows 服务安装文件夹中的 .exe.config 中进行更改。
    猜你喜欢
    • 1970-01-01
    • 2010-10-19
    • 2013-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多