簡體   English   中英

App.config命名空間問題

[英]App.config namespace issue

我正在使用由wsdl生成的接口,在嘗試將我的服務作為Windows服務托管時遇到問題。

以下行出現在界面上方。 除非我從

    [System.ServiceModel.ServiceContractAttribute(Namespace="http://xxxxxx.com/", ConfigurationName="IService")]

    [System.ServiceModel.ServiceContract]

我無法啟動承載程序的Windows服務(事件查看器中的錯誤日志顯示,在Service實施的合同列表中找不到合同IService。)我將端點app.config文件列出為如下:

   endpoint address=""
              binding="basicHttpBinding"
              contract="Service.IService"

當我將合同更改為ServiceContractAttribute中顯示的“ http://xxxxxxx.com/IService ”時,也會發生這種情況。 關於如何解決此問題的任何想法?

配置文件的服務部分:

<service name="Service.Service"
           behaviorConfiguration="myServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8000/Service"/>
      </baseAddresses>
    </host>
    <endpoint address=""
              binding="basicHttpBinding"
              contract="Service.IService" />
    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="Service.IService" />

  </service>
<behaviors>
  <serviceBehaviors>
    <behavior name="myServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="True"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

配置中的終結點元素的合同屬性需要與代碼中ServiceContractAttribute的ConfigurationName屬性的值匹配。 因此,在您的情況下,只需更改配置,使其讀為contract =“ IService”,就可以了。

似乎找不到端點。 您是否使用終端查詢端點,以查看端點是否在提供的地址上進行響應?

“ itowlson”最有可能帶有他的注釋-您的原始服務合同定義了一個配置名稱:

[ServiceContract(Namespace="http://xxxxxx.com/", 
                 ConfigurationName="IService")]

但您的config部分中沒有此類服務配置。

嘗試更改此:

<service name="Service.Service"

<service name="IService"

(或將ServiceContract更改為:

[ServiceContract(Namespace="http://xxxxxx.com/", 
                 ConfigurationName="Service.Service")]

這兩個名稱必須匹配! 或者只是從服務合同中省略配置名稱:

[ServiceContract(Namespace="http://xxxxxx.com/")]

在這種情況下,將基於實際實現服務協定的服務類的Namespace.ServiceClassName模式找到服務配置。

無論哪種方式,您都需要確保ServiceContract屬性和配置文件中的信息匹配。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM