教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Asp.net  >  正文 构建基本的.NET Remoting应用程序

构建基本的.NET Remoting应用程序

发布时间:2018-10-07   编辑:jiaochengji.com
教程集为您提供构建基本的.NET Remoting应用程序等资源,欢迎您收藏本站,我们将为您提供最新的构建基本的.NET Remoting应用程序资源
构建一个使用.NET远程处理框架来进行应用域(application domain )间通信的应用程序很简单。你必须实现远程类型(remotable type)、用于监听请求的服务应用域和客户应用域。同时,你必须为每个应用域配置远程处理系统(remoting system ),以便可以使用远程激活( remote activation )来激活远程类型。
一、创建远程类型(remotable type):
为了使其它应用域中的对象可以使用你的类实例,你的类必须从System.MarshalByRefObject类进行派生。下面的代码说明如何创建远程类:
[Visual Basic]
' RemotableType.vb
Imports System
Public Class RemotableType
Inherits MarshalByRefObject
Private _internalString As String = "This is the RemotableType."

Public Function StringMethod() As String
Return _internalString
End Function 'StringMethod
End Class 'RemotableType
[C#]
// RemotableType.cs
using System;
public class RemotableType : MarshalByRefObject{
private string _internalString = "This is the RemotableType.";
public string StringMethod(){
return _internalString;
}
}
为了使用.NET Framework SDK附带的命令行工具来将上例中的类编译成为库文件,只要将它保存为RemotableType.language-extension(此处language-extension是你所使用的语言,比如cs、vb)。编译时使用如下命令:
[Visual Basic]
vbc /t:library RemotableType.vb
[C#]
csc /noconfig /t:library RemotableType.cs
二、创建服务应用(host application):
要在不同地应用域(application domain)中创建远程对象的实例,你必须创建服务应用来完成两个任务:
(1)选择并且注册一个通道(channel)。该通道是一个处理网络协议和串行格式化(serialization format)的对象。

您可能感兴趣的文章:
.NET Remoting编程简介(转)
.Net远程方法调用研究
构建基本的.NET Remoting应用程序
.NET Remoting 实现分布式数据库查询
MSMQ,Enterprise Service, DotNet Remoting,Web Servi
如何使用 .Net Remoting 实现定向广播
C#反射的一些基本应用
.net面试问答(大汇总),.net求职者不容错过
关于.net中的一些控件,log4net,Atlas
php rpc怎么实现?

[关闭]
~ ~