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

خطاء في web server

مغلق
بدأه lana2008 في 2 يوليو 2007 · 0 رد · 398 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1

حاولت اعمل web server يحسب جمع رقمين بالاعتماد على كتاب dot net remoting للاخ crazy -man

وهذا كود الويب سيرفر

Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Class Main
	Public Shared Sub Main()
		Try
			Dim Channel As TcpChannel = New TcpChannel(1060)
			ChannelServices.RegisterChannel(Channel)
			RemotingConfiguration.RegisterWellKnownServiceType(GetType(IRemotingOperation.IRemotingOperation), "RemotingOperation", WellKnownObjectMode.Singleton)
			Console.WriteLine("The server is started correctlly")
			Console.ReadLine()
		Catch ex As Exception
			Console.WriteLine("The server doesn't started correctlly")
			Console.ReadLine()
		End Try
	End Sub
End Class

وهذا كو العمليات الي يقوم به web server

Public Class Op
	Inherits MarshalByRefObject
	Implements IRemotingOperation.IRemotingOperation
	Dim Value As Integer
	Public Overrides Function InitializeLifetimeService() As Object
		Return Nothing
	End Function
	Public Function Addition(ByVal a As Integer, ByVal b As Integer) As Integer Implements IRemotingOperation.IRemotingOperation.Addition
		Console.WriteLine(String.Format("Calling Addition Function:a={0},b={1}", a, b))
		Return a + b
	End Function
	Public Function Incrementation(ByVal Number As Integer) As Integer Implements IRemotingOperation.IRemotingOperation.Incrementation
		Console.WriteLine(String.Format("Calling Incrementation()Function: Valeur ={0}", Number))
		Value = Value + Number
		Return Value
	End Function
End Class

وهذا كود الفرو م

Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Public Class Form1
	Dim RemoteInterfaces As IRemotingOperation.IRemotingOperation
	Public Sub open()
		InitializeComponent()
		Try
			Dim channel As TcpChannel = New TcpChannel
			ChannelServices.RegisterChannel(channel)
			RemoteInterfaces = (Activator.GetObject(GetType(IRemotingOperation.IRemotingOperation), "tcp://localhost:1060/RemotingOperation"))
		Catch ex As Exception
			MsgBox("Error while trying connecting with server !!")
		End Try
	End Sub
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		'
		'Add
		'
		open()
		Dim r As String
		Try
			If RemoteInterfaces IsNot Nothing Then
				TextBox3.Text = RemoteInterfaces.Addition(Val(TextBox1.Text), Val(TextBox2.Text)).ToString()
			End If
		Catch ex As Exception
			r = ex.Message
			MsgBox(r)
		End Try
	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		'
		'In
		'
		open()
		Dim r As String
		Try
			If RemoteInterfaces IsNot Nothing Then
				TextBox5.Text = RemoteInterfaces.Incrementation(Val(TextBox4.Text)).ToString()
			End If
		Catch ex As Exception
			r = ex.Message
			MsgBox(r)
		End Try
	End Sub

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		'
		'Load
		'
	End Sub
End Class

طبعا في كلاس للعمليات

Public Interface IRemotingOperation
	Function Addition(ByVal a As Integer, ByVal b As Integer) As Integer
	Function Incrementation(ByVal Number As Integer) As Integer
End Interface

هلا الخطاء هو التالي

post-97016-1183406448_thumb.jpg

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

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