<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net%2FNetwork_Remote%2FRemote_Basics</id>
		<title>VB.Net/Network Remote/Remote Basics - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net%2FNetwork_Remote%2FRemote_Basics"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/Network_Remote/Remote_Basics&amp;action=history"/>
		<updated>2026-04-05T13:12:57Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net/Network_Remote/Remote_Basics&amp;diff=954&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/Network_Remote/Remote_Basics&amp;diff=954&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net/Network_Remote/Remote_Basics&amp;diff=955&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/Network_Remote/Remote_Basics&amp;diff=955&amp;oldid=prev"/>
				<updated>2010-05-26T12:45:37Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Call remote object method to Get and set variable==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
///////////////////////////////////general.vb&lt;br /&gt;
// Compile: vbc /target:library  general.vb&lt;br /&gt;
Imports System&lt;br /&gt;
Public Class MyRemoteObject&lt;br /&gt;
    Inherits MarshalByRefObject&lt;br /&gt;
    Private myvalue As Integer&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        Console.WriteLine(&amp;quot;MyRemoteObject.Constructor: New Object created&amp;quot;)&lt;br /&gt;
    End Sub &amp;quot;New&lt;br /&gt;
    Public Sub New(ByVal startvalue As Integer)&lt;br /&gt;
        Console.WriteLine(&amp;quot;MyRemoteObject.Constructor: .ctor called with {0}&amp;quot;, _&lt;br /&gt;
            startvalue)&lt;br /&gt;
        myvalue = startvalue&lt;br /&gt;
    End Sub&lt;br /&gt;
    Public Sub setValue(ByVal newval As Integer)&lt;br /&gt;
        Console.WriteLine(&amp;quot;MyRemoteObject.setValue(): old {0} new {1}&amp;quot;, _&lt;br /&gt;
            myvalue, newval)&lt;br /&gt;
        myvalue = newval&lt;br /&gt;
    End Sub&lt;br /&gt;
    Public Function getValue() As Integer&lt;br /&gt;
        Console.WriteLine(&amp;quot;MyRemoteObject.getValue(): current {0}&amp;quot;, _&lt;br /&gt;
            myvalue)&lt;br /&gt;
        Return myvalue&lt;br /&gt;
    End Function&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////test.vb&lt;br /&gt;
// Compile: vbc /t:exe /r:general.dll test.vb&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Runtime.Remoting&lt;br /&gt;
Imports System.Runtime.Remoting.Channels.Http&lt;br /&gt;
Imports System.Runtime.Remoting.Channels&lt;br /&gt;
Module Client&lt;br /&gt;
    Sub Main()&lt;br /&gt;
        Dim channel As New HttpChannel()&lt;br /&gt;
        ChannelServices.RegisterChannel(channel,false)&lt;br /&gt;
        RemotingConfiguration.RegisterActivatedClientType( _&lt;br /&gt;
            GetType(MyRemoteObject), &amp;quot;http://localhost:1234/MyServer&amp;quot;)&lt;br /&gt;
        Console.WriteLine(&amp;quot;Client.Main(): Creating first object&amp;quot;)&lt;br /&gt;
        Dim obj1 As New MyRemoteObject()&lt;br /&gt;
        obj1.setValue(42)&lt;br /&gt;
        Console.WriteLine(&amp;quot;Client.Main(): Creating second object&amp;quot;)&lt;br /&gt;
        Dim obj2 As New MyRemoteObject()&lt;br /&gt;
        obj2.setValue(11)&lt;br /&gt;
        Console.WriteLine(&amp;quot;Obj1.getValue(): {0}&amp;quot;, obj1.getValue())&lt;br /&gt;
        Console.WriteLine(&amp;quot;Obj2.getValue(): {0}&amp;quot;, obj2.getValue())&lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;br /&gt;
End Module&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////server.vb&lt;br /&gt;
// vbc /target:exe  /r:general.dll server.vb&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Runtime.Remoting&lt;br /&gt;
Imports System.Runtime.Remoting.Channels.Http&lt;br /&gt;
Imports System.Runtime.Remoting.Channels&lt;br /&gt;
Module ServerStartup&lt;br /&gt;
    Sub Main()&lt;br /&gt;
        Console.WriteLine(&amp;quot;ServerStartup.Main(): Server started&amp;quot;)&lt;br /&gt;
        Dim chnl As New HttpChannel(1234)&lt;br /&gt;
        ChannelServices.RegisterChannel(chnl,false)&lt;br /&gt;
        RemotingConfiguration.ApplicationName = &amp;quot;MyServer&amp;quot;&lt;br /&gt;
        RemotingConfiguration.RegisterActivatedServiceType( _&lt;br /&gt;
            GetType(MyRemoteObject))&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
        Console.ReadLine()&lt;br /&gt;
    End Sub&lt;br /&gt;
End Module&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Validate Data remotely==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
///////////////////////////////////general.vb&lt;br /&gt;
// Compile: vbc /target:library  general.vb&lt;br /&gt;
Imports System&lt;br /&gt;
Public Interface IEmployeeManager&lt;br /&gt;
    Function getEmployee(ByVal id As Integer) As Employee&lt;br /&gt;
    Function validate(ByVal cust As Employee) As ValidationResult&lt;br /&gt;
End Interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Serializable()&amp;gt; _&lt;br /&gt;
Public Class ValidationResult&lt;br /&gt;
    Public Sub New(ByVal ok As Boolean, ByVal msg As String)&lt;br /&gt;
        Console.WriteLine(&amp;quot;ValidationResult: Object created&amp;quot;)&lt;br /&gt;
        Me.Ok = ok&lt;br /&gt;
        Me.ValidationMessage = msg&lt;br /&gt;
    End Sub &amp;quot;New&lt;br /&gt;
    Public Ok As Boolean&lt;br /&gt;
    Public ValidationMessage As String&lt;br /&gt;
End Class&lt;br /&gt;
&amp;lt;Serializable()&amp;gt; _&lt;br /&gt;
Public Class Employee&lt;br /&gt;
    Public FirstName As String&lt;br /&gt;
    Public LastName As String&lt;br /&gt;
    Public DateOfBirth As DateTime&lt;br /&gt;
&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        Console.WriteLine(&amp;quot;Employee.constructor: Object created&amp;quot;)&lt;br /&gt;
    End Sub &amp;quot;New&lt;br /&gt;
    Public Function getAge() As Integer&lt;br /&gt;
        Dim tmp As TimeSpan = DateTime.Today.Subtract(DateOfBirth)&lt;br /&gt;
        Return tmp.Days \ 365 &amp;quot; rough estimation&lt;br /&gt;
    End Function&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////test.vb&lt;br /&gt;
// Compile: vbc /t:exe /r:general.dll test.vb&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Runtime.Remoting&lt;br /&gt;
Imports System.Runtime.Remoting.Channels.Http&lt;br /&gt;
Imports System.Runtime.Remoting.Channels&lt;br /&gt;
Module Client&lt;br /&gt;
    Sub Main()&lt;br /&gt;
        Dim channel As New HttpChannel()&lt;br /&gt;
        ChannelServices.RegisterChannel(channel,false)&lt;br /&gt;
        Dim mgr As IEmployeeManager = CType(Activator.GetObject( _&lt;br /&gt;
            GetType(IEmployeeManager), &amp;quot;http://localhost:1234/EmployeeManager.soap&amp;quot;), _&lt;br /&gt;
            IEmployeeManager)&lt;br /&gt;
        Dim cust As New Employee()&lt;br /&gt;
        cust.FirstName = &amp;quot;James&amp;quot;&lt;br /&gt;
        cust.LastName = &amp;quot;Band&amp;quot;&lt;br /&gt;
        cust.DateOfBirth = New DateTime(1999, 5, 12)&lt;br /&gt;
        Dim res As ValidationResult = mgr.validate(cust)&lt;br /&gt;
        Console.WriteLine(&amp;quot;Validation result for {0} {1}&amp;quot; &amp;amp; vbCrLf &amp;amp; _&lt;br /&gt;
            &amp;quot;-&amp;gt; {2}: {3}&amp;quot;, cust.FirstName, cust.LastName, res.Ok.ToString(), _&lt;br /&gt;
            res.ValidationMessage)&lt;br /&gt;
    End Sub&lt;br /&gt;
End Module&lt;br /&gt;
///////////////////////////////////server.vb&lt;br /&gt;
// vbc /target:exe  /r:general.dll server.vb&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Runtime.Remoting&lt;br /&gt;
Imports System.Runtime.Remoting.Channels.Http&lt;br /&gt;
Imports System.Runtime.Remoting.Channels&lt;br /&gt;
Class EmployeeManager&lt;br /&gt;
    Inherits MarshalByRefObject&lt;br /&gt;
    Implements IEmployeeManager&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        Console.WriteLine(&amp;quot;EmployeeManager: Object created&amp;quot;)&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Public Function getEmployee(ByVal id As Integer) As Employee _&lt;br /&gt;
    Implements IEmployeeManager.getEmployee&lt;br /&gt;
        Dim tmp As New Employee()&lt;br /&gt;
        tmp.FirstName = &amp;quot;James&amp;quot;&lt;br /&gt;
        tmp.LastName = &amp;quot;Band&amp;quot;&lt;br /&gt;
        tmp.DateOfBirth = New DateTime(1989, 7, 4)&lt;br /&gt;
        Return tmp&lt;br /&gt;
    End Function&lt;br /&gt;
&lt;br /&gt;
    Public Function validate(ByVal cust As Employee) As ValidationResult _&lt;br /&gt;
    Implements IEmployeeManager.validate&lt;br /&gt;
        Dim age As Integer = cust.getAge()&lt;br /&gt;
        Console.WriteLine(&amp;quot;EmployeeManager.validate() for {0} aged {1}&amp;quot;, _&lt;br /&gt;
            cust.FirstName, age)&lt;br /&gt;
        If cust.FirstName Is Nothing Or cust.FirstName.Length = 0 Then&lt;br /&gt;
            Return New ValidationResult(False, &amp;quot;Firstname missing&amp;quot;)&lt;br /&gt;
        End If&lt;br /&gt;
        If cust.LastName Is Nothing Or cust.LastName.Length = 0 Then&lt;br /&gt;
            Return New ValidationResult(False, &amp;quot;Lastname missing&amp;quot;)&lt;br /&gt;
        End If&lt;br /&gt;
        If age &amp;lt; 0 Or age &amp;gt; 120 Then&lt;br /&gt;
            Return New ValidationResult(False, &amp;quot;Employee must be younger than 120 years&amp;quot;)&lt;br /&gt;
        End If&lt;br /&gt;
        Return New ValidationResult(True, &amp;quot;Validation succeeded&amp;quot;)&lt;br /&gt;
    End Function&lt;br /&gt;
End Class&lt;br /&gt;
Module ServerStartup&lt;br /&gt;
    Sub Main()&lt;br /&gt;
        Console.WriteLine(&amp;quot;ServerStartup.Main(): Server started&amp;quot;)&lt;br /&gt;
        Dim chnl As New HttpChannel(1234)&lt;br /&gt;
        ChannelServices.RegisterChannel(chnl,false)&lt;br /&gt;
        RemotingConfiguration.RegisterWellKnownServiceType( _&lt;br /&gt;
            GetType(EmployeeManager), _&lt;br /&gt;
            &amp;quot;EmployeeManager.soap&amp;quot;, _&lt;br /&gt;
            WellKnownObjectMode.Singleton)&lt;br /&gt;
        &lt;br /&gt;
        Console.ReadLine()&lt;br /&gt;
    End Sub&lt;br /&gt;
End Module&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Your first Remote client and server==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
///////////////////////////////RemoteObject: general.vb&lt;br /&gt;
// Complie: vbc /target:library  general.vb&lt;br /&gt;
&lt;br /&gt;
Public Interface IEmployeeManager&lt;br /&gt;
    Function getEmployee(ByVal id As Integer) As Employee&lt;br /&gt;
End Interface&lt;br /&gt;
&amp;lt;Serializable()&amp;gt; _&lt;br /&gt;
Public Class Employee&lt;br /&gt;
    Public FirstName As String&lt;br /&gt;
    Public LastName As String&lt;br /&gt;
    Public DateOfBirth As DateTime&lt;br /&gt;
&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        Console.WriteLine(&amp;quot;Employee.constructor: Object created&amp;quot;)&lt;br /&gt;
    End Sub &amp;quot;New&lt;br /&gt;
    Public Function getAge() As Integer&lt;br /&gt;
        Console.WriteLine(&amp;quot;In getAge Method&amp;quot;)&lt;br /&gt;
        Return 30&lt;br /&gt;
    End Function&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////test.vb&lt;br /&gt;
// Complie: vbc /t:exe /r:general.dll test.vb&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Runtime.Remoting&lt;br /&gt;
Imports System.Runtime.Remoting.Channels.Http&lt;br /&gt;
Imports System.Runtime.Remoting.Channels&lt;br /&gt;
Imports System.Runtime.Remoting.Proxies&lt;br /&gt;
Imports System.Runtime.Remoting.Messaging&lt;br /&gt;
&lt;br /&gt;
Module Client&lt;br /&gt;
    Sub Main()&lt;br /&gt;
        Dim channel As New HttpChannel()&lt;br /&gt;
        ChannelServices.RegisterChannel(channel,false)&lt;br /&gt;
        Dim mgr As IEmployeeManager = CType(Activator.GetObject( _&lt;br /&gt;
            GetType(IEmployeeManager), &amp;quot;http://localhost:1234/EmployeeManager.soap&amp;quot;), _&lt;br /&gt;
            IEmployeeManager)&lt;br /&gt;
        Console.WriteLine(&amp;quot;Client.Main(): Reference to EmployeeManager acquired&amp;quot;)&lt;br /&gt;
        Dim cust As Employee = mgr.getEmployee(4711)&lt;br /&gt;
        Dim age As Integer = cust.getAge()&lt;br /&gt;
        Console.WriteLine(&amp;quot;Client.Main(): Employee {0} {1} is {2} years old.&amp;quot;, _&lt;br /&gt;
            cust.FirstName, cust.LastName, age)&lt;br /&gt;
        Console.ReadLine()&lt;br /&gt;
    End Sub&lt;br /&gt;
End Module&lt;br /&gt;
&lt;br /&gt;
///////////////////////////server.vb&lt;br /&gt;
// Complie: vbc /target:exe  /r:general.dll server.vb&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Runtime.Remoting&lt;br /&gt;
Imports System.Runtime.Remoting.Channels.Http&lt;br /&gt;
Imports System.Runtime.Remoting.Channels&lt;br /&gt;
Class EmployeeManager&lt;br /&gt;
    Inherits MarshalByRefObject&lt;br /&gt;
    Implements IEmployeeManager&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        Console.WriteLine(&amp;quot;EmployeeManager.constructor: Object created&amp;quot;)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Public Function getEmployee(ByVal id As Integer) As Employee _&lt;br /&gt;
    Implements IEmployeeManager.getEmployee&lt;br /&gt;
        Console.WriteLine(&amp;quot;EmployeeManager.getEmployee): Called&amp;quot;)&lt;br /&gt;
        Dim tmp As New Employee()&lt;br /&gt;
        tmp.FirstName = &amp;quot;James&amp;quot;&lt;br /&gt;
        tmp.LastName = &amp;quot;Band&amp;quot;&lt;br /&gt;
        tmp.DateOfBirth = New DateTime(1007, 7, 4)&lt;br /&gt;
        Console.WriteLine((&amp;quot;EmployeeManager.getEmployee(): Returning &amp;quot; &amp;amp; _&lt;br /&gt;
            &amp;quot;Employee-Object&amp;quot;))&lt;br /&gt;
        Return tmp&lt;br /&gt;
    End Function&lt;br /&gt;
End Class&lt;br /&gt;
Module ServerStartup&lt;br /&gt;
    Sub Main()&lt;br /&gt;
        Console.WriteLine(&amp;quot;ServerStartup.Main(): Server started&amp;quot;)&lt;br /&gt;
        Dim chnl As New HttpChannel(1234)&lt;br /&gt;
        ChannelServices.RegisterChannel(chnl,false)&lt;br /&gt;
        RemotingConfiguration.RegisterWellKnownServiceType( _&lt;br /&gt;
            GetType(EmployeeManager), _&lt;br /&gt;
            &amp;quot;EmployeeManager.soap&amp;quot;, _&lt;br /&gt;
            WellKnownObjectMode.Singleton)&lt;br /&gt;
        &lt;br /&gt;
        Console.ReadLine()&lt;br /&gt;
    End Sub&lt;br /&gt;
End Module&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>