Building a Basic .NET Remoting Application 之四 Compiling and Running the Basic Application

本文介绍如何使用.NET Framework SDK中的命令行工具编译并运行基本的远程应用程序。包括创建可远程类型的类、主机应用程序及客户端应用程序的具体步骤,并演示了如何通过修改配置文件中的通道设置来更改通信通道。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Compiling and Running the Basic Application

To use the command-line tools that ship with the .NET Framework SDK to compile the basic remoting application built in the topics Building a Remotable Type, Building a Host Application, and Building a Client Application, save all files in a directory called Listener, using the names specified in those topics. At the command prompt in the Listener directory, type the following commands:

[C#]

csc /noconfig /t:library RemotableType.cs

csc /noconfig /r:RemotableType.dll Listener.cs

csc /noconfig /r:RemotableType.dll Client.cs

To run the application

  1. Create a subdirectory called Client.
  2. Copy the RemotableType.dll, Client.exe, and Client.exe.config files to the Client directory.
  3. At the command prompt in the Listener directory, type:

    Listener

  4. When the Listener application is running, open a new command prompt in the Client directory and type:

    Client

Changing the Channel

Because the Listener.exe.config and Client.exe.config files contain all the configuration information necessary to make a remote connection, you can change the channel without recompiling your application merely by changing the channel specified in the configuration file.

To change the channel to a TcpChannel object, which uses binary serialization by default, you merely change the <wellknown> element in the Client.exe.config file to the following:

<wellknown
   type="RemotableType, RemotableType"
   url="tcp://localhost:8989/RemotableType.rem"
/>

You must also change the <channel> element in the Listener.exe.config file to the following:

<channel ref="tcp" port="8989"/>

Rerun the application according to the preceding execution instructions. You do not need to recompile the application.

 

转载于:https://www.cnblogs.com/MayGarden/archive/2010/01/04/1639011.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值