Server:
//Class
Namespace Remotingserver
{
Public Class Class1: marshalbyrefobject
{
Public Double Calcsalestax ( Double Salesprice)
{
Return Salesprice * 0.01 ;
}
}
}
// Server console
Using System. runtime. remoting;
Using System. runtime. remoting. channels;
Using Remotingserver;
Namespace Testconsoleapp
{
Public Class Startup
{
Static Void Main ( String [] ARGs)
{Remotingconfiguration. Configure ( @" E: \ _ projects \ DOTNET \ testconsoleapp \ remotingconfig. cfg " , True );
Console. writeline ( " Enter any key to exit " );
Console. readkey ();
}
}
}
Server configuration file:Remotingconfig. cfg
<?XML version = "1.0" encoding = "UTF-8"?>
< Configuration >
< System. runtime. remoting >
< Application Name = "Server" >
< Service >
<! --
<Wellknown type = "space name. Class Name,ProgramSet Name "objecturi =" space name. Class Name"
Mode = "Singleton"/>
<Wellknown... = ""/>
-->
< Wellknown Mode = "Singlecall" Objecturi = "Remotingserver. class1"
Type = "Remotingserver. class1, remotingserver" />
</ Service >
< Channels >
< Channel Ref = "TCP" Port = "9999" >
< Clientproviders >
< Formatter Ref = "Binary" />
</ Clientproviders >
< Serverproviders >
< Formatter Ref = "Binary" Typefilterlevel = "Full" />
</ Serverproviders >
</ Channel >
</ Channels >
</ Application >
</ System. runtime. remoting >
</ Configuration >
Client:
Using System. runtime. remoting;
Using System. runtime. remoting. channels;
NamespaceRemotingclient
{
Public Partial ClassForm1: Form
{
PublicForm1 ()
{
Initializecomponent ();
}
Private Void Btncalc_click ( Object Sender, eventargs E)
{
Remotingserver. class1 CLS = New Remotingserver. class1 ();
Double DREs = Cls. calcsalestax ( Double . Parse ( This . Textbox1.text. Trim ()));
MessageBox. Show (DREs. tostring ( " ###,## 0.00 " ));
}
Private VoidForm1_load (ObjectSender, eventargs E)
{
Remotingconfiguration. Configure (@"E: \ _ projects \ DOTNET \ testconsoleapp \ remotingclient \ clientconfig. cfg",True);
}
}
}
Client configuration file:
<? XML version = "1.0" encoding = "UTF-8" ?>
< Configuration >
< System. runtime. remoting >
< Application Name = "Client" >
< Channels >
< Channel Ref = "TCP" >
< Clientproviders >
< Formatter Ref = "Binary" />
</ Clientproviders >
</ Channel >
</ Channels >
< Client >
<! --
<Wellknown type = "space name. Class Name, assembly name" url = "TCP: // ip: 9999/space name. Class Name"/>
<Wellknown... = ""/>
-->
< Wellknown Type = "Remotingserver. class1, remotingserver" URL = "TCP: // localhost: 9999/remotingserver. class1" />
</ Client >
</ Application >
</ System. runtime. remoting >
</ Configuration >
Project File:/files/wucg/testconsoleapp.rar