首页 新闻 赞助 找找看

C# 命名管道,客户端连接互联网上的服务端,提示“对路径的访问被拒绝”

0
悬赏园豆:5 [已关闭问题] 关闭于 2016-07-03 17:52
try
{
    NamedPipeClient npc = new NamedPipeClient("10.88.39.30", "jc-pipe");
    return npc.Query(MBID);
}
catch (Exception ex)
{
    return ex.Message;
}

 

public NamedPipeClient(string serverName, string pipName)
{
    _serverName = serverName;
    _pipName = pipName;

    _pipeClient = new NamedPipeClientStream(serverName, pipName, PipeDirection.InOut);

}
cnblogsjc的主页 cnblogsjc | 初学一级 | 园豆:199
提问于:2016-07-01 13:06
< >
分享
所有回答(1)
1

设置服务端的访问规则:

PipeSecurity pse = new PipeSecurity();
            pse.SetAccessRule(new PipeAccessRule("Everyone", PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow));
            NamedPipeServerStream npss = new NamedPipeServerStream(_pipName, PipeDirection.InOut, 10, PipeTransmissionMode.Message, PipeOptions.Asynchronous, 1024, 1024, pse, HandleInheritability.None);

cnblogsjc | 园豆:199 (初学一级) | 2016-07-03 17:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册