我得到一個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();
}
}
}
你只是在運行consoleapplica tion.exe在** projectdir \ bin \ debug \ consoleapplication.exe **中找到? – Belogix
jep我做的。我只運行projectdir \ bin \ debug \ consoleapplication.exe –
我們可以從配置 – paramosh