Demo基于http://www.cnblogs.com/zhili/p/NETRemoting.html

RemotingObj

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Metadata;
using System.Text;
using System.Threading.Tasks; namespace RemotingServer
{
public class RemotingObject:MarshalByRefObject
{
public int TestTcpAdd(int first,int second)
{
return first + second;
} public int TestHttpMinus(int first,int second)
{
return first - second;
} [SoapMethod(XmlNamespace = "RemotingServer", SoapAction = "RemotingServer#TestMultiIpc")]
public int TestMultiIpc(int first, int second)
{
return first*second;
}
}
}

  

RemotingServer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Channels.Ipc;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;
using System.Threading.Tasks; namespace RemotingServer
{
class Program
{
static void Main(string[] args)
{
TcpChannel tcpChannel = new TcpChannel(2046);
HttpChannel httpChannel = new HttpChannel(9001);
IpcChannel ipcChannel = new IpcChannel("IpcTest"); ChannelServices.RegisterChannel(tcpChannel,false);
ChannelServices.RegisterChannel(httpChannel,false);
ChannelServices.RegisterChannel(ipcChannel,false); Console.WriteLine("The name of the Tcp Channel:{0}",tcpChannel.ChannelName);
Console.WriteLine("The priority of the Tcp Channel:{0}",tcpChannel.ChannelPriority); Console.WriteLine("The name of the Http Channel:{0}",httpChannel.ChannelName);
Console.WriteLine("The priority of the Http Channel:{0}",httpChannel.ChannelPriority); Console.WriteLine("The name of IPC Channel :{0}",ipcChannel.ChannelName);
Console.WriteLine("The priority of Ipc Channel:{0}",ipcChannel.ChannelPriority); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingServer.RemotingObject), "RemotingObject",WellKnownObjectMode.Singleton);
Console.ReadKey();
}
}
}

  

RemotingClinet

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RemotingServer; namespace RemotingClient
{
class Program
{
static void Main(string[] args)
{
RemotingObject proxyTcp =
Activator.GetObject(typeof (RemotingObject), "tcp://localhost:2046/RemotingObject") as RemotingObject;
if (proxyTcp == null)
{
Console.WriteLine("连接Tcp服务失败!");
return; } RemotingObject proxyHttp =
Activator.GetObject(typeof(RemotingObject), "http://localhost:9001/RemotingObject") as RemotingObject;
if (proxyHttp==null)
{
Console.WriteLine("连接Http服务失败!");
return;
} RemotingObject proxyIpc =
Activator.GetObject(typeof(RemotingObject), "ipc://IpcTest/RemotingObject") as RemotingObject;
if (proxyIpc == null)
{
Console.WriteLine("连接IPC失败!");
return;
} // 输出信息
Console.WriteLine("This call object by TcpChannel, 100 + 200 = {0}", proxyTcp.TestTcpAdd(100, 200));
Console.WriteLine("This call object by HttpChannel, 100 - 200 = {0}", proxyHttp.TestHttpMinus(100, 200));
Console.WriteLine("This call object by IpcChannel, 100 * 200 = {0}", proxyIpc.TestMultiIpc(100, 200));
Console.WriteLine("Press any key to exit!");
Console.ReadLine();
}
}
}

  

备注:

Remoting在HttpChannel下抛“指定的 SOAPAction 无效

解决方法:

1:将Server和Client所在的程序集修改成相同的程序集名。

http://blog.csdn.net/lilin8905/article/details/6232640

2:在需要使用httpChannel的方法上面加上SoapMethod标签

[SoapMethod(XmlNamespace = "命名空间", SoapAction = "命名空间#方法名")]

http://blog.csdn.net/sloder/article/details/8694560

Xmind

练习代码

Remote小Demo的更多相关文章

  1. 新手 gulp+ seajs 小demo

    首先,不说废话,它的介绍和作者就不在多说了,网上一百度一大堆: 我在这里只是来写写我这2天抽空对seajs的了解并爬过的坑,和实现的一个小demo(纯属为了实现,高手请绕道); 一.环境工具及安装 1 ...

  2. Nancy之基于Nancy.Hosting.Self的小Demo

    继昨天的Nancy之基于Nancy.Hosting.Aspnet的小Demo后, 今天来做个基于Nancy.Hosting.Self的小Demo. 关于Self Hosting Nancy,官方文档的 ...

  3. Nancy之基于Nancy.Owin的小Demo

    前面做了基于Nancy.Hosting.Aspnet和Nancy.Hosting.Self的小Demo 今天我们来做个基于Nancy.Owin的小Demo 开始之前我们来说说什么是Owin和Katan ...

  4. Nancy之基于Self Hosting的补充小Demo

    前面把Hosting Nancy with ASP.NET.Self Hosting Nancy和Hosting Nancy with OWIN 以demo的形式简单描述了一下. 这篇是为Self H ...

  5. [Unity3D]做个小Demo学习Input.touches

    [Unity3D]做个小Demo学习Input.touches 学不如做,下面用一个简单的Demo展示的Input.touches各项字段,有图有真相. 本项目已发布到Github,地址在(https ...

  6. Android -- 自定义View小Demo,动态画圆(一)

    1,转载:(http://blog.csdn.NET/lmj623565791/article/details/24500107),现在如下图的效果: 由上面的效果图可以看到其实是一个在一个圆上换不同 ...

  7. Win10 FaceAPI小demo开发问题汇总

    Win10 FaceAPI小demo开发问题汇总 最近使用微软牛津计划做一个小demo,使用FaceAPI做一个小应用,实现刷脸的功能.开发的过程中用到几个问题,具体如下: Stream 与IRand ...

  8. 模仿京东顶部搜索条效果制作的一个小demo

    最近模仿京东顶部搜索条效果制作的一个小demo,特贴到这里,今后如果有用到可以参考一下,代码如下 #define kScreenWidth [UIScreen mainScreen].bounds.s ...

  9. Android学习小Demo一个显示行线的自定义EditText

    今天在处理一个EditText的时候,想着把EditText做成像一本作业本上的纸一样,每一行都可以由线条隔开,具体效果如下: 1)最开始的思路 一开始的想法是很简单的,找出每一行的高度,然后一行一行 ...

随机推荐

  1. VC中如何设置菜单项的触发状态?

    MFC中初始菜单栏如下: 当工程未新建,或者未打开时,后面的观测菜单设置为灰色,不可触发. 当新建工程或者打开工程后,菜单变回可触发状况. 观测菜单如下:   下面以轴力观测菜单为例 轴力初始测量菜单 ...

  2. c# 在datagridview中添加comboboxcolumn 绑定数据库读取显示数据

    datagridview中的comboboxcolumn 从绑定的数据库中读取显示时,只需要注意一点,就是sql语句加个 CStr() 字符串转换函数即可,如下: SELECT CStr(XXX) a ...

  3. Your personal Mail Server iRedMail on ubuntu14.04 x64

    what we have? iRedMail -> http://iredmail.com Get the script over there.          http://www.ired ...

  4. Citrix 服务器虚拟化之三 Xenserver 网络管理

    Citrix 服务器虚拟化之三 Xenserver 网络管理 每个Xenserver服务器都有一个或多个网络.XenServer 网络是虚拟的以太网交换机,它可以连接到外部接口(带或不带 VLAN 标 ...

  5. Linux CPU affinity

    在Linux中,我们知道可以通过nice.renice命令改变进程的执行优先级,优先级高的进程优先执行,从而一定程度上保证重要任务的运行. 除了nice.renice外,可以通过CPU  affini ...

  6. VC++实现小托盘的处理

    // 实验一Dlg.cpp : implementation file // #include "stdafx.h" #include "实验一.h" #inc ...

  7. IOS设计模式学习(7)单例

    1 前言 数学与逻辑学中,singleton定义为“有且仅有一个元素的集合”.因此不管袋子有多大,每次从里面取出弹子的时候,拿到的都是同一个. 2 详述 2.1 简述 面向对象应用程序中的单例类(si ...

  8. 你可能把A/B测试做错了

    大卫奥格威说过,"永远不要停止试验,你的广告也就永远不会停止改进". 在当今的网络世界中,类似于吆喝科技 AppAdhoc A/B Testing 这样的工具越来越多,AB测试和转 ...

  9. Linux笔记(一) - 目录处理命令

    (1)列出文件: ls-a 显示所有文件及目录,包括隐藏文件-l 显示详细信息(长格式显示)-d 显示目录本身-h 人性化显示-i 查看i节点(2)创建目录:mkdir-p 递归创建可以同时创建多个, ...

  10. 《如何阅读一本书》(How to Read a Book)

    值得一读的书,有深入浅出,也有并不能完全读懂的部分,以下是第11章对之前内容的总结整理. 阅读的层次 1. 基础阅读 2. 检视阅读 3. 分析阅读 4. 主题阅读 分析阅读 第一阶段:这本书在谈些什 ...