Net-informations.com
SiteMap  | About    

Remotable Type

Any object outside the application domain of the caller application should be considered as Remote Object. A Remote Object that should be derived from MarshalByRefObject Class. Any object can be changed into a Remote Object by deriving it from MarshalByRefObject . Objects without inheriting from MarshalByRefObject are called Non-remotable Objects.

The following example creating a Remote Object in VB.Net, RemoteTime , which send the current time to the Client Application using Remoting Framework. The RemoteTime class is derived from MarshalByRefObject and inside the class it has a method getTime() which return the current time from Remote Object.




Imports System
Public Class RemoteTime
   Inherits MarshalByRefObject
   Private currentTime As String = ""
   
   Public Function getTime() As String
	  currentTime = DateTime.Now.ToShortTimeString()
      Return "Remote Server Time : " & currentTime
   End Function 

End Class

Copy and paste the above VB.Net source code into a file and save it as RemoteTime.vb
Compile the class RemoteTime.vb into a library using the command-line tools that ship with the .NET Framework SDK.

At the command prompt in the directory in which you saved the file, type the following command:

vbc /t:library RemoteTime.vb

After you compile the RemoteTime.vb , you will get a file called RemoteTime.dll in the directory which you saved the source file.







net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.