2013-03-11 31 views
1

我知道有相同標題的其他問題。我嘗試了他們的解決方案無效服務具有零應用程序(非基礎設施)端點

我收到此消息後嘗試啓動我的服務(Windows託管)註冊後installutil
我沒有WCF的經驗,請耐心等待。

我的服務應用程序由兩個項目組成:Externals,其中包含我的服務接口,客戶端接口,數據協定和app.config以及Internals,它包含服務實現(這是主機,實際實現是在沒有從我的服務接口繼承的另一個文件中完成,我不確定這是否是一種好的做法)。
我的app.config:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <services> 
     <service name="Internals.ExecutionService" behaviorConfiguration="Default"> 
     <endpoint name="TCPEndpoint" 
        address="net.tcp://localhost:8080/ExecutionService" 
        binding ="netTcpBinding" 
        contract="Externals.IExecutionService"/> 
     <endpoint address="mex" 
        binding="mexTcpBinding" 
        contract="IMetadataExhange"/> 
     <host> 
      <baseAddresses> 
      <add baseAddress="netTcp://localhost:8080/ExecutionService"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="Default"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

我的界面:

using System.ServiceModel; 

namespace Externals 
{ 
    [ServiceContract(CallbackContract = typeof(IClientCallback))] 
    public interface IExecutionService 
    { 
     /// <summary> 
     /// Executes the mainflow.py file in the provided location. 
     /// </summary> 
     /// <param name="path">Path to the Python file.</param> 
     /// <returns>Execution status. Expected to return Passed/Failed onlt.</returns> 
     [OperationContract] 
     ExecutionStatus Execute(string path); 

     [OperationContract] 
     ExecutionStatus GetStatus(); 
    } 
} 

和執行(這是真的還沒有準備好,我只是想看看我是否能得到一個客戶端添加服務參考):

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)] 
    public partial class ExecutionService : ServiceBase, IExecutionService 
    { 
     ServiceHost myHost; 
     private IClientCallback callbackChannel; 

     public ExecutionService() 
     { 
      InitializeComponent(); 
     } 

     protected override void OnStart(string[] args) 
     { 
      myHost = new ServiceHost(typeof(ExecutionService)); 
      myHost.Open(); 
     } 
} 

接口的空白實現。

完整的錯誤:

Service cannot be started. System.InvalidOperationException: Service 'Internals.ExecutionService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element. 
    at System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreApplicationEndpoints(ServiceDescription description) 
    at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) 
    at System.ServiceModel.ServiceHostBase.InitializeRuntime() 
    at System.ServiceModel.ServiceHostBase.OnBeginOpen() 
    at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Open() 
    at Internals.ExecutionService.OnStart(String[] args) in C:\Users... 

從事件查看器服用。

+0

我想你是混合Windows服務和WCF服務的實現。這些是兩個獨立的實體,試圖將它們分成兩類,每一類都有一個問題。 Windows服務不應該執行合同。 – nvoigt 2013-03-11 12:23:23

+0

別忘了將實際的wcf app.config serviceModel部分複製到winservice app.config – SalientBrain 2013-03-11 14:52:39

+0

什麼是winservice app.config? – Noich 2013-03-11 14:53:38

回答

1

你的app.config應該是內部的,而不是外部的。將它重命名爲Internals.exe.config(或任何你的「內部」exe文件命名)並將它放在與你的服務exe相同的目錄中。

相關問題