Call remote object method to Get and set variable : Remote Basics « Network Remote « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VB.Net » Network Remote » Remote BasicsScreenshots 
Call remote object method to Get and set variable

///////////////////////////////////general.vb
// Compile: vbc /target:library  general.vb
Imports System

Public Class MyRemoteObject
    Inherits MarshalByRefObject

    Private myvalue As Integer

    Public Sub New()
        Console.WriteLine("MyRemoteObject.Constructor: New Object created")
    End Sub 'New

    Public Sub New(ByVal startvalue As Integer)
        Console.WriteLine("MyRemoteObject.Constructor: .ctor called with {0}", _
            startvalue)
        myvalue = startvalue
    End Sub

    Public Sub setValue(ByVal newval As Integer)
        Console.WriteLine("MyRemoteObject.setValue(): old {0} new {1}", _
            myvalue, newval)
        myvalue = newval
    End Sub

    Public Function getValue() As Integer
        Console.WriteLine("MyRemoteObject.getValue(): current {0}", _
            myvalue)
        Return myvalue
    End Function

End Class



///////////////////////////////////test.vb
// Compile: vbc /t:exe /r:general.dll test.vb
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels.Http
Imports System.Runtime.Remoting.Channels

Module Client

    Sub Main()
        Dim channel As New HttpChannel()
        ChannelServices.RegisterChannel(channel,false)

        RemotingConfiguration.RegisterActivatedClientType_
            GetType(MyRemoteObject)"http://localhost:1234/MyServer")

        Console.WriteLine("Client.Main(): Creating first object")

        Dim obj1 As New MyRemoteObject()

        obj1.setValue(42)

        Console.WriteLine("Client.Main(): Creating second object")
        Dim obj2 As New MyRemoteObject()
        obj2.setValue(11)

        Console.WriteLine("Obj1.getValue(): {0}", obj1.getValue())
        Console.WriteLine("Obj2.getValue(): {0}", obj2.getValue())


    End Sub

End Module





///////////////////////////////////server.vb
// vbc /target:exe  /r:general.dll server.vb
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels.Http
Imports System.Runtime.Remoting.Channels

Module ServerStartup

    Sub Main()
        Console.WriteLine("ServerStartup.Main(): Server started")

        Dim chnl As New HttpChannel(1234)
        ChannelServices.RegisterChannel(chnl,false)

        RemotingConfiguration.ApplicationName = "MyServer"
        RemotingConfiguration.RegisterActivatedServiceType_
            GetType(MyRemoteObject))


        
        Console.ReadLine()

    End Sub
End Module



           
       
Related examples in the same category
1. Your first Remote client and server
2. Validate Data remotely
w_w_w__._j___a__va___2s___.___co__m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.