如何解决"该ChannelDispatcher无法打开其IChannelListener"错误? [英] How to solve "The ChannelDispatcher is unable to open its IChannelListener" error?

查看:1357
本文介绍了如何解决"该ChannelDispatcher无法打开其IChannelListener"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想传达的Windows服务和我服务的GUI之间WCF主持。问题是,当我试图执行OperationContract的方法,我收到




的ChannelDispatcher在
'的net.tcp ://本地主机:7771 /为MyService
合同(S)'IContract'是
无法打开其IChannelListener


$ b $。 b

我app.conf看起来像:

 <结构> 
< system.serviceModel>
<&绑定GT;
<&NetTcpBinding的GT;
<绑定名称=NetTcpBinding的>
<安全>
<运输的ProtectionLevel =EncryptAndSign/>
< /安全>
< /&结合GT;
< / NetTcpBinding的>
< /绑定>
<&行为GT;
< serviceBehaviors>
<行为NAME =MyServiceBehavior>
< serviceMetadata httpGetEnabled =真httpGetUrl =HTTP://本地主机:7772 /为MyService/>
< serviceDebug includeExceptionDetailInFaults =真/>
< /行为>
< / serviceBehaviors>
< /行为>
<服务和GT;
<服务behaviorConfiguration =MyServiceBehavior
NAME =MyService.Service>
<端点地址=的net.tcp://本地主机:7771 /为MyService绑定=NetTcpBinding的
bindingConfiguration =NetTcpBinding的NAME =netTcp合同=MyService.IContract/> ;
< /服务>
< /服务>
< /system.serviceModel>





端口7771是听(检查用netstat)和SvcUtil工具能够产生CONFIGS我。



任何建议,将不胜感激。






堆栈异常跟踪




 服务器堆栈跟踪:
。在系统.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(消息回复,MessageFault故障,串动,MessageVersion版本,faultConverter faultConverter)
在System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime操作,ProxyRpc&安培; RPC)
在System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime操作,对象[]项,对象[]奏,时间跨度超时)
在System.ServiceModel.Channels.ServiceChannel.Call(串动,布尔单向,ProxyOperationRuntime操作,对象[]项,对象[]奏)
在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作)
在System.ServiceModel.Channels.ServiceChannelProxy .Invoke(即时聊天消息)







有一个内部exeption(但不Exeption.InnerExeption下,但在Exeption.Detail.InnerExeption - ToString()方法不显示)




一个注册已经存在URI的net.tcp://本地主机:7771 /为MyService。




不过,我的服务只在app.config文件无处指定此URI。在整个解决方案此URI apears服务器一次,客户一旦


解决方案

我解决了它:D



下面是问题的explanaition:



首先不好的代码:

 命名空间WCFServer 
{
公共类节目:IWCFService
{
私人ServiceHost的主机;

静态无效的主要(字串[] args)
{
新计划();
}

公共计划()
{
主机=新的ServiceHost(typeof运算(计划));

host.Open();

Console.WriteLine(服务器开始吧!);

Console.ReadKey();
}

#地区IWCFService会员

公众诠释CheckHealth(INT ID)
{
回报(1);
}

#endregion
}
}

正如你所看到的服务合同是在类中实现托管服务。这引起了整个事情的错误(也许typeof运算()运行一个构造函数,我不知道我愿意在这个问题上有建设性的意见)。



好码

 命名空间WCFServer 
{
公共类节目
{
私人的ServiceHost主办;

静态无效的主要(字串[] args)
{
新计划();
}

公共计划()
{
主机=新的ServiceHost(typeof运算(WCF));

host.Open();

Console.WriteLine(服务器开始吧!);

Console.ReadKey();
}
}

公共类WCF:IWCFService
{

#地区IWCFService会员

公众诠释CheckHealth(中间体ID)
{
返回(1);
}

#endregion
}
}

服务合同的两个文件:

  [的ServiceContract] 
公共接口IWCFService
{
〔OperationContract的]
INT CheckHealth(INT ID);
}



App.config中



 <结构> 
< system.serviceModel>
<&行为GT;
< serviceBehaviors>
<行为NAME =WCFBehavior/>
< / serviceBehaviors>
< /行为>
<&绑定GT;
<&NetTcpBinding的GT;
<绑定名称=tcpBinding>
<安全>
<运输及GT;
< extendedProtectionPolicy policyEnforcement =从不/>
< /运输及GT;
< /安全>
< /&结合GT;
< / NetTcpBinding的>
< /绑定>
<服务和GT;
<服务名称=WCFServer.WCF>
<端点地址=的net.tcp://本地主机:1111 / TcpIHostMonitor绑定=NetTcpBinding的
bindingConfiguration =tcpBindingNAME =netTcpEndpoint合同=WCFServer.IWCFService/> ;
< /服务>
< /服务>
< /system.serviceModel>




I'm trying to communicate between WCF hosted in Windows Service and my service GUI. The problem is when I'm trying to execute OperationContract method I'm getting

"The ChannelDispatcher at 'net.tcp://localhost:7771/MyService' with contract(s) '"IContract"' is unable to open its IChannelListener."

My app.conf looks like that:

<configuration>
<system.serviceModel>
    <bindings>
        <netTcpBinding>
            <binding name="netTcpBinding">
                <security>
                    <transport protectionLevel="EncryptAndSign" />
                </security>
            </binding>
        </netTcpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="MyServiceBehavior">
                <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:7772/MyService" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="MyServiceBehavior"
            name="MyService.Service">
            <endpoint address="net.tcp://localhost:7771/MyService" binding="netTcpBinding"
                bindingConfiguration="netTcpBinding" name="netTcp" contract="MyService.IContract" />
        </service>
    </services>
</system.serviceModel>

Port 7771 is listening (checked using netstat) and svcutil is able to generate configs for me.

Any suggestions would be appreciated.


Stack trace from exception

Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)


There's one inner exeption (but not under Exeption.InnerExeption but under Exeption.Detail.InnerExeption - ToString() method doesn't show that)

A registration already exists for URI 'net.tcp://localhost:7771/MyService'.

But my service have specified this URI only in app.config file nowhere else. In entire solution this URI apears in server once and client once.

解决方案

I solved it :D

Here's the explanaition of the problem:

First BAD code:

namespace WCFServer
{
    public class Program : IWCFService
    {
        private ServiceHost host;

        static void Main(string[] args)
        {
            new Program();
        }

        public Program()
        {
            host = new ServiceHost(typeof(Program));

            host.Open();

            Console.WriteLine("Server Started!");

            Console.ReadKey();
        }

        #region IWCFService Members

        public int CheckHealth(int id)
        {
            return (1);
        }

        #endregion
    }
}

As you can see the service contract is implemented in class hosting the service. This caused the whole error thing (maybe typeof() runs a constructor, i don't know I'm open to constructive input in this matter).

The GOOD code:

namespace WCFServer
{
    public class Program
    {
        private ServiceHost host;

        static void Main(string[] args)
        {
            new Program();
        }

        public Program()
        {
            host = new ServiceHost(typeof(WCF));

            host.Open();

            Console.WriteLine("Server Started!");

            Console.ReadKey();
        }
    }

    public class WCF : IWCFService
    {

        #region IWCFService Members

        public int CheckHealth(int id)
        {
            return (1);
        }

        #endregion
    }
}

Service Contract for both files:

[ServiceContract]
public interface IWCFService
{
    [OperationContract]
    int CheckHealth(int id);
}

App.config

<configuration>
<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="WCFBehavior" />
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <netTcpBinding>
            <binding name="tcpBinding">
                <security>
                    <transport>
                        <extendedProtectionPolicy policyEnforcement="Never" />
                    </transport>
                </security>
            </binding>
        </netTcpBinding>
    </bindings>
    <services>
        <service name="WCFServer.WCF">
            <endpoint address="net.tcp://localhost:1111/TcpIHostMonitor" binding="netTcpBinding"
                bindingConfiguration="tcpBinding" name="netTcpEndpoint" contract="WCFServer.IWCFService" />
        </service>
    </services>
</system.serviceModel>

这篇关于如何解决&QUOT;该ChannelDispatcher无法打开其IChannelListener&QUOT;错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆