惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - 小乔的闺房

学习ID,ClientID,UniqueID 基础知识1 (1)将对象序列化为bin,soap,xml (4)迭代器 (3)集合接口 (1)学习数组,集合,IEnumerable接口,引申学习迭代器 (2)学习集合,引申学习索引器和泛型 自定义服务器控件(1)整体把握(未完待续) FindControl实现原理 location详解 使用ASP.NET AJAX实现(图片)幻灯片效果 固定GridView列字符串长度,多于的用...代替 读取Excel数据到GridView相关问题(待完善) 说明nchar(10),char(10),nvarchar(10),varchar(10) syscolumns 获得数据库里所有表的名称 类[属性扩展],属性[属性扩展](待完善) 获得数据库表的列数 WebForm里弹出警告框之内的自定义类MessageBox
(2)最简单的Remoting程序
小乔的闺房 · 2007-11-04 · via 博客园 - 小乔的闺房

(1) 编写3步走
(类库)对象General
(控制台应用程序)服务器端Server:添加对象的dll引用
(控制台应用程序)客户端Client:添加对象的dll引用

(2) 对象
using System;
using System.Collections.Generic;
using System.Text;
namespace RemotingExample
{
    public class Hello : MarshalByRefObject
    {
        public Hello()
        {
            Console.WriteLine("Hello对象被建立");
        }

        public string SayHello(string strClientName)
        {
            return " Hello ! " + strClientName;
        }
    }
}

(3) 服务期端代码
using System;
using System.Collections.Generic;
using System.Text;
//添加的using
using RemotingExample;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
//添加System.Runtime.Remoting引用才能添加以下2个using
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;

namespace RemotingExample
{
    public class Server
    {
        public static int Main(string[] args)
        {
            TcpChannel myTcpChannel = new TcpChannel(8085);//申请tcp通道
            HttpChannel myHttpChannel = new HttpChannel(8086);//申请http通道
            ChannelServices.RegisterChannel(myTcpChannel, false);//注册tcp通道
            ChannelServices.RegisterChannel(myHttpChannel, false);//注册http通道

            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(Hello),
                "SayHello",
                WellKnownObjectMode.Singleton
                );

            System.Console.WriteLine(" Press Enter key to exit ");
            System.Console.ReadLine();
            return 0;
        }
    }
}

(4) 客户端代码
using System;
using System.Collections.Generic;
using System.Text;
//添加的using
using RemotingExample;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
//添加System.Runtime.Remoting引用才能添加以下2个using
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;

namespace RemotingExample
{
    class Client
    {
        public static int Main(string[] args)
        {
            //使用TCP通道获得远程对象
            TcpChannel myTcpChannel = new TcpChannel();
            ChannelServices.RegisterChannel(myTcpChannel, false);
            Hello myHelloTCP = (Hello)Activator.GetObject(typeof(Hello), "tcp://localhost:8085/SayHello");
            if (myHelloTCP == null)
            {
                System.Console.WriteLine("Could not locate TCP server");
            }
            //使用HTTP通道获得远程对象
            HttpChannel myHttpChannel = new HttpChannel();
            ChannelServices.RegisterChannel(myHttpChannel, false);
            Hello myHelloHTTP = (Hello)Activator.GetObject(typeof(Hello), "http://localhost:8086/SayHello");
            if (myHelloHTTP == null)
            {
                System.Console.WriteLine("Could not locate TCP server");
            }

            //[TCP]调用远程对象的方法
            System.Console.WriteLine("TCP: " + myHelloTCP.SayHello("miclu"));

            //[HTTP]调用远程对象的方法
            System.Console.WriteLine("HTTP: " + myHelloHTTP.SayHello("miclu"));

            System.Console.ReadLine();
            return 0;
        }
    }
}

这样代码就写死了,下节学习使用Remoting配置文件