• Distributed programming is a concept of sharing application logic over the network A collection of computers, which are connected together is called as a network
  • A collection of computers , which are connected together is called as a network
  • To establish a network, a protocol is required protocol provides a set of rules, which need to be allowed while transferring the data over the network Generally network can be established with the help TCP or HTTP Protocol.


Generally distributed programming is required to develop3- Tier or N- Tier architectures.





Working with .NET Remoting

  1. .NET Remoting helps to develop distributed programming architecture.
  2. Distributed programming allows to share the logic over the network.
  3. Distributed programming allows to develop secured applications.




  1. The connection in between two computers is called as a “channel”.
  2. Remoting supports HTTP Channel and Tep channel
  3. The communication in between two CLR’s is also called as .NET remoting
  4. To start the communication a PORT need to be reserved.
  5. The starting point of a communication channel is called as PORT.
  6. Os supports o to 65535 ports, from which some ports are PRE-RESERVED.





Web logic Servers-----7070,8080,9090

  1. .NET Remoting Architecture






  1. Converting object stream into byte stream is called as “Marshalling” and vice versa is called as “De- Marshalling”.
  2. Marshalling will be done with the help of STUB and De-Marshalling by skeleton.
  3. To work with .NET remoting, micro soft introduced system Run time.Remoting Assembly
  4. Marshal By Ref object is a predefined class, which helps in Marshalling and De-Marshalling

In order share the Logic, Some Reouree files need to be copied from server machine into client machine.



4 Steps for Developing Remoting Application:-

Step1:- Write an interface with a set of abstract methods and compile into a DLL file.


Step2:- Write a server program by overriding Inter face methods and Reserve a channel over a PORT.


Step3:- Write a client program to create a connection with server and call interface methods.


Step4:- Start server then start client programs



The interface DLL must be copied into both server and client machines.


Developing 3- Tier Architecture with Remoting:-






Screenshot_24Open oracle software and create a table with name users and with two columns used and pwd

Screenshot_24Create table users(Usid varchor2(20),

Pwd varchar 2(10));

Screenshot_24Add two records as follows

Insert into users values(‘teja’, ’abc’);

Insert into users values(‘Ravu’, ’xyz’);

Screenshot_24Save or commit;


  1. Developing Interface with a let of abstract methods

Screenshot_24Open class Library project with project name Middle Interface.

Name space middle Interface


Public interface MI


Bool check user(String a, String b);


}Middle Inter face

Screenshot_24Build the project(build menuScreenshot_24 Build solution)

Obs:- Middle interface.dll is created under

D:/C194/ Middle interface\Bin\Debug folder


  1. Developing server Application

Screenshot_24Open console Application project with project name Middle server

Screenshot_24 project menuàadd referenceà

System. Runtime. Remoting

Screenshot_24Project menuàAdd referenceàbrowseà

Middle Interface.DLL

Screenshot_24Using system. Run time. Remoting;

Screenshot_24 Using system. Run time. Remoting. channels;

Screenshot_24Using system. Run time. Remoting channels. TCP;

Screenshot_24Using system. Data. oleDb;

Screenshot_24Code in GD(Before Main)


Class M Server: Marsha L By Ret object, HI


Public bool check user(String a, string b)


String q=”select* from users where

Usid=’”+a+”’ and pwd=’”+”’;

oleDb connection cn = new oleDb connection

(“user id = scott; password= tiger;provider=msdaora.1”);

oleDb command cmd= new oleDb command(;

object obj=cmd. Execute scalor();


Return false;


Return true;

}//check user method

}//m server class

àcode for main()


TCP channel t= new TCP channel(1600);

Channel Services. Register channel(t);

Remoting configuration. Register well known service type

(type of (m server),”abc”, well known object mode

Single call);

Console. write line(“server is ready to use”);

Console. Read key();


Screenshot_24Execute the project

Then a TCP Server will be created with the following URL

Tcp://Local host:1600/abc

  1. Developing a client application

Screenshot_24open a new .NET Window(startàrunàdevenr)

Screenshot_24open WFAP with project name Middle client

Screenshot_24Project menuà Add ReferenceàBrowseà

Middle Interface.DLL

Screenshot_24Design the form as shown

Screenshot_24Using middle Interface;

Screenshot_24code for button1-click


MI X=(MI)Activator. Get object(type of(MI)”tcp://Local host:1600/abc”);

BooL B= X. Check user (text box1.text,Text box2. text);


Message box. show(“valid user”);


Message box. show(“not a valid user”);






Remoting configuration. Register well known service type() takes3 arguments


Org 1) Type of the class, where interface methods are over rided .


Org 2) Provide an alias name to the server


Org3) Specifies mode of the communication


Remoting supports two types of communication model with the help of well known object mode enum





Screenshot_24Single call is tastes in communication when compared with single ton

Screenshot_24In single call, a separate object will be created for every client

Screenshot_24In single  ton, only one object will be created for all the clients

When number of clients are limited then use single all other wise use single ton

Activator class is used to open a connection with my specified URL

2 Developing an application like yahoo messenger  with off line support and two consecutive messages quid not be same




Screenshot_24Open class library project with project name yahoo Inter face


Public Interface YI


String Get TEXT();



Screenshot_24Build the project(Build menuScreenshot_24Build solution)



Yahoo Interface.dll is created under

D:\C194/Yahoo Interface/Bin/Debug folder

Screenshot_24Open windows farms Application project with project name yahoo server

Screenshot_24Design the form as follows:-

Screenshot_24ProjectScreenshot_24Add ReferenceScreenshot_24

System. Run time. Remoting

Screenshot_24project menuScreenshot_24 Add ReferenceScreenshot_24BroweScreenshot_24

Yahoo Interface.DLL

Using system. Runtime. Remoting;

Using system. Runtime. Remoting. channels;

Using system. Runtime. Remoting. Channels.TCP;

Using Yahoo Interface;

Screenshot_24Code in GD

Static string S;

Class y server: Marshal By Ret Object.YI


Public string Get text()


Return Farm1.s;

}//Get Text

}//4 Server

Screenshot_24Code for Button1-click(send)


Forml. s=text box2.text;


Code for farm1-load Event


TCP Channel=new TCP Channel(4829);

Channel Services. Register channel(t);

Remoting configuration. Register well known Service type(type of (4 Server),”yahoo”, well known object mode. single ton);

Text box1.text=”server is Ready”;


Screenshot_24Execute the project



Then a tcp server will be created with the following URL

Tcp://Local host:4829/yahoo

Screenshot_24Developing client application

Screenshot_24Open a new .NET Window

Screenshot_24Open WFAP with project name yahoo client

Screenshot_24Place two text boxes, one button and a timer control with enabled = false

Screenshot_24Project menuScreenshot_24Add referenceScreenshot_24BrowseScreenshot_24Yahoo Interface.dll

Screenshot_24Using yahoo Interface;

Screenshot_24code in GD

String s1,s2;


Screenshot_24code for formal – Load event


X=(YI)Activator. Get Object(type of (yI)

“tcp://Local host:4829/yahoo”);

Text box1.text=x. get text();



àcode for time:-1-tick event


S1-X.Get Text();

If(s1 !=s2)

Text box1.text=text box1.text+

Environment.  new line+s1;








  1. Security is a concept of restricting Anonymous(unknown)accessibility.
  2. C#.NET Supports security in two ways:-
  3. Crypto Graphy
  4. Role Based Security