zoukankan      html  css  js  c++  java
  • C#中Remoting的IPC通信之Winform与Windows服务通信错误问题及解决

    按照传统的写法我试过好多次都发现通过Winform向Windows服务发送消息Windows服务收不到,而在两个Winform程序之间却可以正常通信。代码如下:

    IpcServerChannel serverChannel = new IpcServerChannel("ipc");
    ChannelServices.RegisterChannel(serverChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingObject), "hi", WellKnownObjectMode.SingleCall);

    后来在查找解决此问题的方法时看到别人写过的代码:

               IpcServer Channel BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
    provider.TypeFilterLevel = TypeFilterLevel.Full;
    Hashtable ht = new Hashtable();
    ht["portName"] = "ServerChannel";
    ht["name"] = "ipc";
    ht["authorizedGroup"] = "Everyone";
    serverChannel = new IpcServerChannel(ht, provider);
    ChannelServices.RegisterChannel(serverChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingObject), "hi", WellKnownObjectMode.Singleton);

    这样试了一下,在Windows服务中可以收到消息了。

      

  • 相关阅读:
    微信端video去除最顶层播放
    MVC错误页面相关说明
    sublime使用
    linux或Mac下手动回滚代码
    用Python操作git命令
    利用pyinstaller打包加密Python项目
    进程、线程和协程的结合使用
    模块导入失败问题
    递归调用解压zip包或rar包
    随机验证码&发红包
  • 原文地址:https://www.cnblogs.com/gisser/p/2308989.html
Copyright © 2011-2022 走看看