2015-01-27 1 views
0

IIS 8.5에서 실행되는 WCF 서비스가 있습니다. Windows Forms 프로젝트 및 콘솔 응용 프로그램 프로젝트에서 서비스를 사용하고 테스트했으며 정상적으로 작동합니다. 하지만 비주얼 스튜디오에서 ServiceModel은 서비스 클라이언트 구성 섹션에서 계약 'bindSignalR.bindSinalRService'을 참조 2013클래스 라이브러리 응용 프로그램에서 WCF 서비스를 사용할 수 없습니다.

찾을 수 없습니다 기본 끝점 요소를 클래스 라이브러리 프로젝트에서 웹 서비스를 소비 할 수 없습니다입니다. 이는 응용 프로그램에 대한 구성 파일이 없거나이 계약에 일치하는 엔드 포인트 요소가 클라이언트 요소에 없기 때. 일 수 있습니다.

Windows Forms Project (작동하는) 및 클래스 라이브러리 프로젝트의 구성 파일을 조사했지만 차이점을 찾을 수 없습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

서비스의의 Web.config은 다음과 같습니다

<configuration> 
    <system.web> 
     <compilation targetFramework="4.0" /> 
    </system.web> 

    <system.serviceModel> 
        <behaviors> 
      <serviceBehaviors> 
       <behavior name=""> 
        <serviceMetadata httpGetEnabled="true" /> 
        <serviceDebug includeExceptionDetailInFaults="true" /> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
     <bindings> 
      <customBinding> 
       <binding name="bindSignalRService.Web.bindSinalRService.customBinding0"> 
        <binaryMessageEncoding /> 
        <httpTransport /> 
       </binding> 
           </customBinding> 
     </bindings> 
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
      multipleSiteBindingsEnabled="true" /> 
     <services> 
      <service name="bindSignalRService.Web.bindSinalRService"> 
       <endpoint address="" binding="customBinding" bindingConfiguration="bindSignalRService.Web.bindSinalRService.customBinding0" 
        contract="bindSignalRService.Web.bindSinalRService" /> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
      </service> 
     </services> 
    </system.serviceModel> 
</configuration> 

윈도우 형태로의 app.config (이 잘 작동!) 응용 프로그램 :

<configuration> 
    <configSections> 
    </configSections> 
    <system.serviceModel> 
     <bindings> 
      <customBinding> 
            <binding name="CustomBinding_bindSinalRService"> 
        <binaryMessageEncoding /> 
        <httpTransport /> 
       </binding> 
      </customBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://slascvm042:49904/bindSinalRService.svc" 
       binding="customBinding" bindingConfiguration="CustomBinding_bindSinalRService" 
       contract="bindNewEventService.bindSinalRService" name="CustomBinding_bindSinalRService" /> 

     </client> 
    </system.serviceModel> 
</configuration> 

하지만 소비 할 때 클래스 라이브러리 응용 프로그램의 WCF 서비스 오류가 발생했습니다. ServiceModel 클라이언트 구성 섹션에서 계약 'bindSignalR.bindSinalRService'를 참조하는 기본 끝점 요소를 찾을 수 없습니다. 이는 응용 프로그램에 대한 구성 파일이 없거나이 계약에 일치하는 엔드 포인트 요소가 클라이언트 요소에 없기 때. 일 수 있습니다.

+0

내가 점점 오전 오류가 굵게 및 중앙의 하나입니다. –

+0

어떤 상황에서 오류가 발생합니까? 나는 네가 예외가 있다는 것을 의미한다고 믿는다. 스택 추적 및 내부 예외를 포함하여 전체 예외를 게시하십시오. 문제 해결을 위해이 작업을 수행하는 간단한 방법은 예외를 잡아 내고'ex.ToString()'의 결과를 게시하는 것입니다. –

+0

클래스 라이브러리를 호스팅하는 프로세스는 무엇입니까? 라이브러리를 호스팅하는 앱의 구성이 위의 구성으로 업데이트되지 않은 것 같습니다. –

답변

1

해결 : 도와 주셔서 감사합니다. 나는 이것 (많은 시간과 많은 시간 투자)에 정말로 힘든 시간을 보내고 있었다.

라이브러리 응용 프로그램에서 웹 서비스를 사용할 때 (라이브러리를 사용할 때마다) app.config 파일의 끝점과 바인딩 섹션을 라이브러리에서 (웹/응용 프로그램) .config는 당신이 사용하고자하는 proyect에서 라이브러리입니다 !!! (잘못된 점이 있으면 수정하십시오.) 내 경우

내가 복사 :

<system.serviceModel> 
    <bindings> 
     <customBinding> 
      <binding name="bind"> 
       <binaryMessageEncoding /> 
       <httpTransport /> 
      </binding> 
     </customBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:49904/bindSinalRService.svc" 
      binding="customBinding" bindingConfiguration="bind" contract="bindSignalRService.Web.bindSinalRService" 
      name="myEnpointName" /> 
    </client> 
</system.serviceModel> 
+0

사실, 이것은 항상 클래스 라이브러리에 해당됩니다. _Whatever_는 클래스 라이브러리의 app.config에 저장되며 소비하는 응용 프로그램의 app.config 또는 web.config로 이동해야합니다. 1 일부터이 방법이 사용되었습니다. 라이브러리의 소비자가 두 명 이상일 수 있으며 라이브러리 별 구성은 각 소비자마다 다를 수 있습니다. –

관련 문제