我已经开始学习WCF,并且已经成功地创建了一些测试http服务。现在,我正在尝试使用net.pipe绑定创建一个自托管的WCF服务。以下是该服务的配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="MEX" name="InProcService.MyService">
<endpoint address="MyService"
binding="netNamedPipeBinding" bindingConfiguration="" contract="InProcService.IMyService" />
<endpoint address="Mex" binding="mexNamedPipeBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/InProcService/" />
<add baseAddress="http://localhost:8001/InProcService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MEX" >
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>现在,在我的主机应用程序中,我使用以下命令启动服务:-
ServiceHost host = new ServiceHost(typeof(MyService));
host.Open();
Console.WriteLine("Service started");
host.Close();当执行此代码时,服务将正确启动。
现在,当我在客户端应用程序中尝试将服务引用添加到这个正在运行的服务时,它无法找到它。是否有我没有做或做得不正确的地方?
如果我能得到任何帮助,我将不胜感激。
干杯,阿比。
发布于 2011-08-03 14:48:20
在那之后,服务被打开和关闭。当您启动客户端时,服务器已经关闭。因此,在关闭之前需要使用Console.ReadKey()。
https://stackoverflow.com/questions/4606319
复制相似问题