Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB.NET Remoting

VB.NET Remoting

Scheduled Pinned Locked Moved Visual Basic
questioncsharpsysadminalgorithms
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chris Quick
    wrote on last edited by
    #1

    I have been searching for simple examples of how to do remoting with VB.NET. What I desire is a remoting object that exposes some shared functions to return other objects. I am currently using console applications as my test environment. Here is my object that should be created by the shared function and returned to the client.

    <Serializable()> _
    Public Class SampleObject
        Private mName
        Private mData
    
        Public Sub New()
            Console.WriteLine("Object Created")
        End Sub
     
        Public Property Name() As String
            Get
                Return mName
            End Get
            Set(ByVal Value As String)
                mName = Value
            End Set
        End Property
     
        Public Property Data() As String
            Get
                Return mData
            End Get
            Set(ByVal Value As String)
                mData = Value
            End Set
        End Property
     
        Public Overrides Function ToString() As String
            Return mName & " " & mData
        End Function
    End Class
    

    Now, my server has a class that will populate the object:

    Public Class Creator
        Inherits MarshalByRefObject
    
        Public Shared Function CreateSampleObject() As RemotingObject.SampleObject
            Dim NewObj As New RemotingObject.SampleObject
            NewObj.Name = "Hello"
            NewObj.Data = "World"
    
            Return NewObj
        End Function
    End Class
    

    The problem is that I do not understand where the Creator needs to be. Does a reference need to exist in both the client and server? If not, how do I activate a class of the object. Here is my server console application:

    Imports System.Runtime.Remoting
    Imports System.Runtime.Remoting.Channels
    Imports System.Runtime.Remoting.Channels.Tcp
    
    Module Server
    
        Sub Main()
    
            RemotingConfiguration.ApplicationName = "Server"
            RemotingConfiguration.RegisterWellKnownServiceType( _ 
                                   GetType(Creator), "object.rem", _ 
                                   WellKnownObjectMode.SingleCall)
    
            Dim mChannel As New TcpChannel(1441)
            ChannelServices.RegisterChannel(mChannel)
            mChannel.StartListening(Nothing)
            Console.WriteLine("Listening on port: 1441")
            Console.ReadLine()
            mChannel.StopListening(Nothing)
        End Sub
    
    End Module
    

    Finally, the client (as it stands right now -- and it doesn't work)

    Imports System.Runtime.Remoting
    Imports System.Runtime.Remoting.Channels
    Imp
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups