الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

.net Remoting

مغلق
بدأه maldehnee في 7 نوفمبر 2007 · 5 رد · 917 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم و رحمة الله و بركاته

أرجو المساعده في كتابة برنامج بسيط يتم من خلاله ما يلي:

simple client calls a method on a remote object where it live on a server application , this method triggers an event (on the server application ) and the event must be handled in the client application by using .net remoting

#3

i wrote a simple a pplication and the following problem faced me:

The Error Says :Type 'Client.Client' in Assembly 'Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Here is the code:

'RemoteObject.vb

Public Delegate Sub DisplayHandler(ByVal message As String)

Public Class MyObject

Inherits MarshalByRefObject

Public Event Display As DisplayHandler

Public Sub DisplayMessage(ByVal message As String)

RaiseEvent Display(message)

End Sub

Public Overrides Function InitializeLifetimeService() As Object

Return Nothing

End Function

End Class

'client.vb

Imports System.Runtime.Remoting

Imports System.Runtime.Remoting.Channels

Imports System.Runtime.Remoting.Channels.Tcp

Imports RemoteObject

Module Module1

Sub Main()

Dim c As New Client()

c.Run()

End Sub

End Module

Public Class Client

Public Sub Run()

ChannelServices.RegisterChannel(New TcpChannel(0), False)

Dim r As MyObject = CType(Activator.GetObject(GetType(MyObject), "tcp://localhost:8080/Server"), MyObject)

AddHandler r.Display, AddressOf Me.Print

r.DisplayMessage("Mohammad")

Console.ReadLine()

End Sub

Public Sub Print(ByVal message As String)

Console.WriteLine(message)

End Sub

End Class

Server.vb

Imports System.Runtime.Remoting

Imports System.Runtime.Remoting.Channels

Imports System.Runtime.Remoting.Channels.tcp

Imports RemoteObject

Module Module1

Sub Main()

ChannelServices.RegisterChannel(New TcpChannel(8080), False)

RemotingConfiguration.RegisterWellKnownServiceType(GetType(MyObject), "Server", WellKnownObjectMode.Singleton)

Console.WriteLine("Press Enter to Exit")

Console.ReadLine()

End Sub

End Module

Take into consideration that all are placed in the same solution

#5

Here is the full solution

RemotingApplication.rar

هذا الموضوع مغلق.

مواضيع مشابهة