Remoting test project

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.