2009-10-30 32 views
1

我有兩個名爲TemplateService,TemplateReportService(都定義在一個WCF服務庫中)的服務暴露給客戶端應用程序。WCF庫中的App.config及其Windows服務主機

而且,我試圖在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> 

所以,在app.config在我的Windows服務(我在哪裏舉辦上述兩項服務) 將同上或僅存在我需要移動的某些特定部分。

請指導。

謝謝!

回答

4

首先,刪除正如我們在你的其他問題中談到的。第二個庫沒有自己的.config文件,並且沒有(內置)方式來導入.NET中的某些配置節。因此,您必須將每個庫的配置設置合併到Windows服務的單個app.config中。

+0

感謝您的回覆。我所做的錯誤是將app.config從WCF庫複製到Windows服務安裝文件夾。而我只需在Windows服務安裝文件夾中的.exe.config中進行更改。 – iniki 2009-11-02 13:07:17