Click here to Skip to main content
15,912,205 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRecursive <xml> via path Pin
DADANEPAL1-Oct-04 18:52
DADANEPAL1-Oct-04 18:52 
GeneralRe: Recursive <xml> via path Pin
DADANEPAL1-Oct-04 18:57
DADANEPAL1-Oct-04 18:57 
GeneralDBEngine.OpenDatabase generates... "Name DBEngine is not declared" !!! Pin
Harvester1321-Oct-04 18:17
Harvester1321-Oct-04 18:17 
GeneralRe: DBEngine.OpenDatabase generates... "Name DBEngine is not declared" !!! Pin
Mekong River2-Oct-04 4:23
Mekong River2-Oct-04 4:23 
GeneralRe: DBEngine.OpenDatabase generates... "Name DBEngine is not declared" !!! Pin
Harvester1322-Oct-04 15:19
Harvester1322-Oct-04 15:19 
GeneralRe: DBEngine.OpenDatabase generates... "Name DBEngine is not declared" !!! Pin
Dave Kreskowiak2-Oct-04 17:40
mveDave Kreskowiak2-Oct-04 17:40 
GeneralRe: DBEngine.OpenDatabase generates... "Name DBEngine is not declared" !!! Pin
Harvester1323-Oct-04 5:22
Harvester1323-Oct-04 5:22 
GeneralVB.NET Remoting Pin
Chris Quick1-Oct-04 12:21
Chris Quick1-Oct-04 12:21 
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
Imports System.Runtime.Remoting.Channels.Tcp

Module Client

    Sub Main()

        Dim TCP As New TcpChannel(1441)
        ChannelServices.RegisterChannel(TCP)

        RemotingConfiguration.RegisterWellKnownClientType( _ 
              Type.GetType("RemotingServer.Creator"), _ 
              "tcp://localhost:1441/Server/object.rem")

        Dim NewCreator As Object = Activator.GetObject( _ 
               Type.GetType("RemotingServer.Creator"), _ 
               "tcp://localhost:1441/Server/object.rem")

        Dim NewObj As RemotingObject.SampleObject = _ 
                               NewCreator.CreateSampleObject
        Console.WriteLine(NewObject.ToString)
        Console.ReadLine()

    End Sub

End Module


Thanks for any input or articles/sample code that I can get my hands on!
GeneralPrinting in Vb.net through Rich Text Box Pin
eshban2841-Oct-04 11:11
eshban2841-Oct-04 11:11 
GeneralRe: Printing in Vb.net through Rich Text Box Pin
Dave Kreskowiak1-Oct-04 13:34
mveDave Kreskowiak1-Oct-04 13:34 
GeneralListBox in a Datagrid Pin
tdk0071-Oct-04 10:04
tdk0071-Oct-04 10:04 
GeneralRe: ListBox in a Datagrid Pin
Jim Matthews1-Oct-04 10:55
Jim Matthews1-Oct-04 10:55 
Generalplease help me to lower the immage size Pin
Dr yousef1-Oct-04 5:45
sussDr yousef1-Oct-04 5:45 
GeneralRe: please help me to lower the immage size Pin
Dave Kreskowiak1-Oct-04 13:33
mveDave Kreskowiak1-Oct-04 13:33 
GeneralButton Images Pin
Britnt71-Oct-04 4:23
Britnt71-Oct-04 4:23 
GeneralRe: Button Images Pin
Jim Matthews1-Oct-04 5:00
Jim Matthews1-Oct-04 5:00 
GeneralRe: Button Images Pin
Britnt71-Oct-04 5:58
Britnt71-Oct-04 5:58 
GeneralRe: Button Images Pin
Britnt71-Oct-04 8:25
Britnt71-Oct-04 8:25 
Generalnetworkaccess Pin
jeeju1-Oct-04 2:33
jeeju1-Oct-04 2:33 
GeneralRe: ordnetworkaccess Pin
Dave Kreskowiak1-Oct-04 2:55
mveDave Kreskowiak1-Oct-04 2:55 
GeneralRe: networkaccess Pin
jeeju5-Oct-04 1:36
jeeju5-Oct-04 1:36 
Questionwhat the error is ... anyone could help?? Pin
Fired Dragon1-Oct-04 1:32
Fired Dragon1-Oct-04 1:32 
AnswerRe: what the error is ... anyone could help?? Pin
Gavin Jeffrey1-Oct-04 2:18
Gavin Jeffrey1-Oct-04 2:18 
GeneralRe: what the error is ... anyone could help?? Pin
Fired Dragon1-Oct-04 2:31
Fired Dragon1-Oct-04 2:31 
Generalclient-side functionality Pin
pyb30-Sep-04 23:10
pyb30-Sep-04 23:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.