最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
构建基本的.NET Remoting应用程序
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
一、创建远程类型(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)的对象。
-
上一个: 创建ASP.NET数据存储层(3)
-
下一个: 创建ASP.NET数据存储层(2)
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10