2013-05-22 56 views
1

我得到一個noopy問題,如果我在VS內運行我自己託管的WCF(WCF服務Lib +控制檯應用程序)服務一切正常。 如果我想在項目目錄中運行consoleapplication.exe,它看起來像一切工作正常,但它不會。 (i'm新的C#)WCF自託管服務運行ConsoleApp.exe dosn't工作,但內vs2012井

I`ve測試: 運行它爲管理員(防火牆關閉和開啓) 通過HTTP reservate我的服務urlacl

作品,我可以訪問我的服務好工具遠程。 工程不好意味着我不能通過本地主機訪問它。

是否缺少任何依賴關係?

預先感謝您!

的App.config的consoleApp的:

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="NewBehavior"> 
       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" 
        policyVersion="Default" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="NewBehavior" name="SampleEmpServiceLib.EmpService"> 
      <clear /> 
      <endpoint address="basic" binding="basicHttpBinding" contract="SampleEmpServiceLib.IEmpService" 
       listenUriMode="Explicit" /> 
      <endpoint address="http://localhost:8060/EmpS" binding="wsDualHttpBinding" bindingConfiguration="" 
       contract="SampleEmpServiceLib.IEmpService" listenUriMode="Explicit" /> 
      <endpoint address="net.tcp://localhost:8888/EmpS" binding="netTcpBinding" 
       contract="SampleEmpServiceLib.IEmpService" listenUriMode="Explicit" /> 
      <endpoint address="net.pipe://localhost/EmpS" binding="netNamedPipeBinding" 
       contract="SampleEmpServiceLib.IEmpService" listenUriMode="Explicit" /> 
      <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" 
       contract="IMetadataExchange" /> 
      <host> 
       <baseAddresses> 
        <add baseAddress="http://localhost:8080/EmpS/" /> 
       </baseAddresses> 
      </host> 
     </service> 
    </services> 
</system.serviceModel> 

的代碼中的Program.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.ServiceModel; 
using System.Text; 
using SampleEmpServiceLib; 
using System.ServiceModel.Description; 
namespace ConsoleApplication 
{ 
class Program 
{ 
    static void Main(string[] args) 
    { 
     ServiceHost host = new ServiceHost(typeof(EmpService)); 

     host.Open(); 
     Console.WriteLine("running on endpoints:"); 
     foreach (ServiceEndpoint serviceEndpoint in host.Description.Endpoints) 
      Console.WriteLine(serviceEndpoint.Address.ToString()); 

     Console.WriteLine("running"); 
     Console.ReadLine(); 
     host.Close(); 
    } 
} 

}

+0

你只是在運行consoleapplica tion.exe在** projectdir \ bin \ debug \ consoleapplication.exe **中找到? – Belogix

+0

jep我做的。我只運行projectdir \ bin \ debug \ consoleapplication.exe –

+0

我們可以從配置 – paramosh

回答

1

我可以推薦一些更新配置:

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="NewBehavior"> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" 
       policyVersion="Default" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="NewBehavior" name="SampleEmpServiceLib.EmpService"> 
     <clear /> 
     <endpoint binding="basicHttpBinding" contract="SampleEmpServiceLib.IEmpService" listenUriMode="Explicit" /> 
     <endpoint address="dual" binding="wsDualHttpBinding" bindingConfiguration="" contract="SampleEmpServiceLib.IEmpService" listenUriMode="Explicit" /> 
     <endpoint binding="netTcpBinding" contract="SampleEmpServiceLib.IEmpService" listenUriMode="Explicit" /> 
     <endpoint binding="netNamedPipeBinding" contract="SampleEmpServiceLib.IEmpService" listenUriMode="Explicit" /> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8080/EMPS" /> 
      <add baseAddress="net.tcp://localhost:8888/EMPS" /> 
      <add baseAddress="net.pipe://localhost/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    </system.serviceModel> 
+0

現在我定製了我的app.config thx! –

+0

我的問題仍然存在......其中關係站在應用程序。我的服務庫配置到我的控制檯的app.config? ESP。我的端點 –

+1

如果我理解的正確性比沒有關係正確,那麼對於正在運行的應用程序,您只有一個app.config。這意味着你應該將servicemodel複製到控制檯app.config – paramosh