2009-10-02 4 views
0

콘솔 앱을 통해 시작하는 Windows 서비스에서 WCF 서비스를 호스팅하려고합니다. 각 서비스는 콘솔 앱과 마찬가지로 자체 프로젝트입니다. WCF 서비스 라이브러리의 app.config를 콘솔 응용 프로그램의 app.config에 복사했지만 "서비스에는 응용 프로그램 끝점이 없습니다 ..."라는 메시지가 계속 나타납니다. 나는 몇몇 장소에서 오류가 내 타입 참조가 완전하지 않다는 것을 의미하지만, 나는 double (트리플, 쿼드 러플 ...)을 체크했다. 그리고 저는 app.config를 가지고 있다고 확신합니다. 디버그 디렉토리에는 Console App, Console App vshost, Win Service 등 3 개의 exes가 있습니다. 윈 서비스는 app.config를 가지고 있지 않았기 때문에, app.config 파일을 찾고자 할 때를 대비해 복사를 시도했지만 운이 없었다. 또한 configs의 이름이 올바르게 지정되었는지 확인했습니다 (< 프로그램 > .exe.config).WCF 서비스 자체 호스팅 문제

다음은 내가 사용하는 것입니다. 내 콘솔 앱은 JobSchdeuler의 인스턴스를 만들고 JobSchedulerConsoleStart을 호출합니다.

호스트 코드 :

public partial class JobScheduler : ServiceBase 
{ 
    ServiceHost jobServiceHost = null; 

    public JobScheduler() 
    { 
     ServiceName = "JobSchedulerService"; 
     InitializeComponent(); 
    } 

    #region Service Init/Uninit 

    /// <summary> 
    /// OnStart 
    /// </summary> 
    /// <param name="args"></param> 
    protected override void OnStart(string[] args) 
    { 
     if (jobServiceHost != null) 
     { 
      jobServiceHost.Close(); 
     } 

     jobServiceHost = new ServiceHost(typeof(JobSchedulerWCF.JobService)); 

     jobServiceHost.Open(); 
    } 

    /// <summary> 
    /// OnStop 
    /// </summary> 
    protected override void OnStop() 
    { 
     if (jobServiceHost != null) 
     { 
      jobServiceHost.Close(); 
      jobServiceHost = null; 
     } 
    } 

    #endregion 

    #region Debugging 

    public void JobSchedulerConsoleStart() 
    { 
     this.OnStart(null); 
     Console.WriteLine("Service Started."); 

     ProcessInput(); 

     Console.WriteLine("Service Stopped."); 
     this.OnStop(); 
    } 

    private void ProcessInput() 
    { 
     Console.WriteLine("Press any key to quit..."); 
     Console.ReadKey(); 
    } 

    #endregion 
} 

의 app.config는

<?xml version="1.0"?> 
<configuration> 
    <system.serviceModel> 
     <services> 
      <service behaviorConfiguration="JobSchedulerWCF.Service1Behavior" name="JobSchedulerWCF.JobService, JobSchedulerWCF"> 
       <endpoint address="" binding="wsHttpBinding" contract="JobSchedulerWCF.IJobServiceController, JobSchedulerWCF"> 
        <identity> 
         <dns value="localhost" /> 
        </identity> 
       </endpoint> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
       <host> 
        <baseAddresses> 
         <add baseAddress="http://localhost:12345/jobService"/> 
        </baseAddresses> 
       </host> 
      </service> 
     </services> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="JobSchedulerWCF.Service1Behavior"> 
        <!-- To avoid disclosing metadata information, 
         set the value below to false and remove the metadata endpoint above before deployment --> 
        <serviceMetadata httpGetEnabled="True"/> 
        <!-- To receive exception details in faults for debugging purposes, 
         set the value below to true. Set to false before deployment 
         to avoid disclosing exception information --> 
        <serviceDebug includeExceptionDetailInFaults="False" /> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
    </system.serviceModel>   
</configuration> 
+0

호스트 코드도 제공해 주시겠습니까? – Philippe

+0

코드가 제공되었습니다. –

답변

0

나는 결코 이것의 바닥에 이르지 못했다. config/프로젝트에는 약간의 문제가있었습니다. 나는 해결책을 재건했고 문제는 사라졌다.

0

이 구성 파일은 Console.App.exe.config

  • Win.Service

    • 명명 된 마십시오. exe.config

    ?

    편집 : 올바르게 기억해두면 WCF 및 서비스 이름의 베타 버전에 문제가있는 것입니다.

    은 설정 파일에서 어셈블리 이름을 제거

    <service behaviorConfiguration="JobSchedulerWCF.Service1Behavior" name="JobSchedulerWCF.JobService"> 
    

    <service behaviorConfiguration="JobSchedulerWCF.Service1Behavior" name="JobSchedulerWCF.JobService, JobSchedulerWCF"> 
    

    을 변경하려고합니다.

    문제가 해결되는지 알려주세요. 나는 묶지 않았다.

  • +0

    예, 그렇습니다. 나는 이것을 포함시키기 위해 내 글을 업데이트했다. –

    관련 문제