.net remoting
来源:互联网 发布:python instanceof 编辑:程序博客网 时间:2024/04/29 00:07
Share Library:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
namespace DotNetRemoteTest
{
public class ResumeLoader : System.MarshalByRefObject
{
public ResumeLoader()
{
System.Console.WriteLine("Hello,it 's a dot net remoting test");
}
public Resume GetResumeByUserID(decimal userID)
{
Resume resume = new Resume(userID);
resume.UserID = userID;
resume.Title = "BackHam";
resume.ResumeID = 1001;
// resume.Body = "M U";
return resume;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace DotNetRemoteTest
{
[Serializable]
public class Resume
{
private decimal resumeID, userID;
private String body, title;
public Resume(decimal resumeID)
{
this.ResumeID = resumeID;
this.UserID = 1;
this.Body = "This is the default body of the resume";
this.Title = "This is the default Title";
}
public decimal ResumeID
{
get { return resumeID; }
set { this.resumeID = value; }
}
public decimal UserID
{
get { return userID; }
set { this.userID = value; }
}
public String Body
{
get { return body; }
set
{
this.body = value;
}
}
public String Title
{
get { return title; }
set
{ this.title = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using DotNetRemoteTest;
using System.IO;
namespace ResumeClient
{
public class ResumeClient
{
public static void Main(String[] args)
{
try
{
ChannelServices.RegisterChannel(new TcpClientChannel(), false);
ResumeLoader loader = (ResumeLoader)Activator.GetObject(typeof(ResumeLoader), "tcp://10.167.28.158:9932/ResumeLoader");
if (loader == null)
{
Console.WriteLine("unable get remote referance");
}
else
{
Resume resume = loader.GetResumeByUserID(1002);
Console.WriteLine("resumeid = " + resume.ResumeID);
Console.WriteLine("userid = " + resume.UserID);
Console.WriteLine("title = " + resume.Title);
Console.WriteLine("body = " + resume.Body);
}
Console.ReadLine();
}
catch (Exception e)
{
StreamWriter sw;
sw = File.AppendText("log.txt");
sw.WriteLine("["+ System.DateTime .Now .ToLongTimeString() + "] " );
sw.WriteLine(e.ToString() + "/n");
sw.Flush();
sw.Close();
StreamReader reader = File.OpenText("log.txt");
String line;
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine(line);
}
reader.Close();
Console.ReadLine();
}
}
}
}
- [Remoting] 一:.NET Remoting
- [Remoting] 一:.NET Remoting
- .NET Remoting
- .NET Remoting
- .Net Remoting
- .net remoting
- .NET Remoting
- .net remoting
- .Net Remoting
- .net remoting
- .net remoting
- .NET Remoting
- .NET Remoting
- .NET Remoting
- .NET Remoting 体系结构评估
- 认识.NET Remoting
- .NET Remoting 安全性
- .Net Remoting印象
- 预处理命令总结!
- ARM 和 Cortex 嵌入式系统NAND Flash编程
- 富人意识
- 【转贴】GCC-the GNU Complier Collection
- Linux下解压压缩及打包命令大全
- .net remoting
- MyEclipse6.5 注册码
- loopback端口作用
- printf格式控制符的完整格式
- 转@ 标准基础知识汇总〖新手学习必读〗-机电商情网
- ssh整合的三种方式
- Servlet编程API
- vc2005中运行控制台程序后暂停的方法
- 【转贴】论GNU、Linux和GNU/Linux之间的关系