WCF命名管道错误:管道已结束。 (109,0x6d) [英] WCF Named Pipe Error: The pipe has been ended. (109, 0x6d)

查看:358
本文介绍了WCF命名管道错误:管道已结束。 (109,0x6d)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过对付其他职位管道已结束。(109 0x6d),但他们都没有解决我的问题。我有过这个博客的一个相对简单的设置基地:的http://高科技.PRO /补习/ 855 / WCF的教程基本的进程间通信



我觉得我跟着它非常密切,只有删除HTTP绑定。



下面是服务器代码:

 公共类InterProcessServer:IInterProcessServer 
{
私人的ServiceHost _host = NULL;

公共事件的EventHandler< CommandLineArgsEventArgs> CommandLineArgsReceived;

保护InterProcessServer(URI serverAddress,弦乐服务名)
{
IPassCommandLineArgs passArgs = NULL;
passArgs = CreatePassCommandLineArgs();
passArgs.CommandLineArgsReceived + =新的EventHandler< CommandLineArgsEventArgs> passArgs_CommandLineArgsReceived);

_host =新的ServiceHost(passArgs,新的URI [] {serverAddress});
_host.AddServiceEndpoint(typeof运算(IPassCommandLineArgs),新NetNamedPipeBinding(),服务名);
_host.Open();
}

公共静态IInterProcessServer CreateInterProcessServer(URI serverAddress,弦乐服务名)
{
返回新InterProcessServer(serverAddress,服务名);
}

公共无效的Dispose()
{

{
_host.Close();
}
赶上{}
}

私人无效passArgs_CommandLineArgsReceived(对象发件人,CommandLineArgsEventArgs E)
{
事件处理程序和LT; CommandLineArgsEventArgs>处理器= CommandLineArgsReceived;

如果(处理!= NULL)
处理器(发件人,E);
}

受保护的虚拟IPassCommandLineArgs CreatePassCommandLineArgs()
{
返回新PassCommandLineArgs();
}
}

下面是客户端代码:

 公共类InterProcessClient:IInterProcessClient 
{
私人IPassCommandLineArgs _pipeProxy = NULL;
私人的ChannelFactory< IPassCommandLineArgs> _pipeFactory = NULL;

保护InterProcessClient(URI serviceAddress)
{
_pipeFactory =新的ChannelFactory< IPassCommandLineArgs>(新NetNamedPipeBinding(),新的EndpointAddress(serviceAddress));
_pipeProxy = _pipeFactory.CreateChannel();
}

公共静态IInterProcessClient CreateInterProcessClient(URI serviceAddress)
{
返回新InterProcessClient(serviceAddress);
}

公共无效SendArgs(字串[] args)
{
_pipeProxy.PassArgs(参数);
}


公共无效的Dispose()
{

{
如果(_pipeFactory!= NULL)
_pipeFactory.Close();
}
赶上{}
}
}

我已经确保了客户端连接到该地址是正确的。任何人都可以提供一个想法,为什么我可能会得到当 _pipeProxy.PassArgs(参数)的错误; 从客户叫什么?该测试只是在不同的进程运行在同一台机器上的两个控制台应用程序之间。



框架4.0 BTW。



感谢



修改这里是服务接口和实现:

  [的ServiceContract] 
公共接口IPassCommandLineArgs
{
事件的EventHandler< CommandLineArgsEventArgs> CommandLineArgsReceived;

[OperationContract的]
无效PassArgs(字串[] args);
}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
公共类PassCommandLineArgs:IPassCommandLineArgs
{
公共事件的EventHandler< CommandLineArgsEventArgs> CommandLineArgsReceived;

公共无效PassArgs(字串[] args)
{
&事件处理LT; CommandLineArgsEventArgs>左撇子= CommandLineArgsReceived;

如果(左撇子!= NULL)
投手(这一点,新CommandLineArgsEventArgs(){参数数量= ARGS});
}
}


解决方案

确定。这是通过在具有无效字符到客户端的地址调用代码的问题。仅此而已。


I have looked at the other posts dealing with "The pipe has been ended. (109, 0x6d)" but none of them have solved my problem. I have a relatively simple setup bases off of this blog: http://tech.pro/tutorial/855/wcf-tutorial-basic-interprocess-communication

I feel like I follow it pretty closely, only removing the HTTP binding.

Here is the server code:

public class InterProcessServer : IInterProcessServer 
{
    private ServiceHost _host = null;

    public event EventHandler<CommandLineArgsEventArgs> CommandLineArgsReceived;

    protected InterProcessServer(Uri serverAddress, string serviceName)
    {
        IPassCommandLineArgs passArgs = null;
        passArgs = CreatePassCommandLineArgs();
        passArgs.CommandLineArgsReceived += new EventHandler<CommandLineArgsEventArgs> passArgs_CommandLineArgsReceived);

        _host = new ServiceHost(passArgs, new Uri[] { serverAddress });
        _host.AddServiceEndpoint(typeof(IPassCommandLineArgs), new NetNamedPipeBinding(), serviceName);
        _host.Open();
    }

    public static IInterProcessServer CreateInterProcessServer(Uri serverAddress, string serviceName)
    {
        return new InterProcessServer(serverAddress, serviceName);
    }

    public void Dispose()
    {
        try
        {
            _host.Close();
        }
        catch { }
    }

    private void passArgs_CommandLineArgsReceived(object sender, CommandLineArgsEventArgs e)
    {
        EventHandler<CommandLineArgsEventArgs> handler = CommandLineArgsReceived;

        if (handler != null)
            handler(sender, e);
    }

    protected virtual IPassCommandLineArgs CreatePassCommandLineArgs()
    {
        return new PassCommandLineArgs();
    }
}

Here is the client code:

public class InterProcessClient : IInterProcessClient
{
    private IPassCommandLineArgs _pipeProxy = null;
    private ChannelFactory<IPassCommandLineArgs> _pipeFactory = null;

    protected InterProcessClient(Uri serviceAddress)
    {
        _pipeFactory = new ChannelFactory<IPassCommandLineArgs>(new NetNamedPipeBinding(), new EndpointAddress(serviceAddress));
        _pipeProxy = _pipeFactory.CreateChannel();
    }

    public static IInterProcessClient CreateInterProcessClient(Uri serviceAddress)
    {
        return new InterProcessClient(serviceAddress);
    }

    public void SendArgs(string[] args)
    {
        _pipeProxy.PassArgs(args);           
    }


    public void Dispose()
    {
        try
        {
            if (_pipeFactory != null)
                _pipeFactory.Close();
        }
        catch { }
    }
}

I have ensured that the address the client is connecting to is correct. Can anyone provide an idea why I might be getting the error when _pipeProxy.PassArgs(args); is called from the client? The test is just between two console apps on the same machine running in different processes.

Framework 4.0 btw.

Thanks!

EDIT Here is the service interface and implementation:

[ServiceContract]
public interface IPassCommandLineArgs
{
    event EventHandler<CommandLineArgsEventArgs> CommandLineArgsReceived;

    [OperationContract]
    void PassArgs(string[] args);
}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class PassCommandLineArgs : IPassCommandLineArgs
{
    public event EventHandler<CommandLineArgsEventArgs> CommandLineArgsReceived;

    public void PassArgs(string[] args)
    {
        EventHandler<CommandLineArgsEventArgs> hander = CommandLineArgsReceived;

        if (hander != null)
            hander(this, new CommandLineArgsEventArgs() { Args = args });
    }
}

解决方案

OK. This was an issue of the calling code passing in an address that had an invalid character to the client. Nothing more.

这篇关于WCF命名管道错误:管道已结束。 (109,0x6d)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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