我创建了WCF自托管服务,我托管它在C#控制台应用程序中,它在那里运行完美,但问题是,当我把本地URL在浏览器中,然后它不浏览+我不能添加它的参考Web表单客户端应用程序,它会引发错误:无法添加WCF服务参考
There was an error downloading 'http://localhost:8084/_vti_bin/ListData.svc/$metadata'.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8084
Metadata contains a reference that cannot be resolved: 'http://localhost:8084/'.
There was no endpoint listening at http://localhost:8084/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8084
If the service is defined in the current solution, try building the solution and adding the service reference again.
我运行托管在VS 2013的独立实例和客户端在另一个作为管理员,但它不能正常工作,为什么?
CODE:
托管应用:
namespace HellloServiceHost
{
class Program
{
static void Main(string[] args)
{
using(ServiceHost sh = new ServiceHost(typeof(HellloService.HelloService)))
{
sh.Open();
Console.WriteLine("Host Started @"+ System.DateTime.Now.ToShortDateString());
Console.ReadLine();
}
}
}
}
的app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="HellloService.HelloService" behaviorConfiguration="MexBehaviour" >
<endpoint address="HelloService" binding="basicHttpBinding" contract="HellloService.IHelloService"></endpoint>
<endpoint address="HelloService" binding="netTcpBinding" contract="HellloService.IHelloService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8084/"/>
<add baseAddress="net.tcp://localhost:8085/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors >
<behavior name="MexBehaviour">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
有没有任何答案可以帮助你。 – flayn