Here, in the Client application in C# , creating an instance of the Remote Type , RemoteTime Object , and call the method getTime() . Additionally it uses the configuration file Client.exe.config for the communication information for the Remoting Framework.
Full Example Code :
using System;
using System.Runtime.Remoting;
public class Client
{
public static void Main()
{
RemotingConfiguration.Configure("Client.exe.config");
RemoteTime remoteTimeObject = new RemoteTime();
Console.WriteLine(remoteTimeObject.getTime());
}
}
Copy and paste the above C# source code into a file and save it as Client.cs .
We have to create additional configuration file to provide the communication information to the Client Object . The configuration file is a an XML structured file. We can specify the Remote Type , Channel , port for communication etc. through the configuration file.
Click here to download Client.exe.config
Compile the class file Client.cs using the command-line tools that ship with the Visual Studio SDK .
At the command prompt type the following command:
csc /r:RemoteTime.dll Client.cs
After you compile the Client.cs , you will get a file called Client.exe in the directory where your compiler resides.
If your file Client.cs and RemoteTime.dll is residing in c:\src then you should type command like the following :
csc /r:c:\src\RemoteTime.dll c:\src\Client.cs
Nice tutorial code. when do not runing. :D
Trả lờiXóacode demo chưa full để hoạt động đâu bạn
XóaCode chưa ok bạn nha.
Xóađúng rồi đó a :D
Trả lờiXóa