Unable to connect to the remote server in Vb.net Remoting

May 26 2006 12:12 AM


I have Written one Remoting  programme in   . Vb net , I am using SoapFormatter
I am Run the Porgramme i got this Error

"Unable to connect to the remote server"

Pls advise Me .

public
Class CreditCardValidator

Inherits MarshalByRefObject

Public Sub New()

Console.WriteLine("Component initialized...")

End Sub

Public Function Validate(ByVal strCCNumber As String) As Boolean

Dim strRev As String

Dim strCh As String

Dim intNumber As Integer

Dim strNumberFinal As String

Dim intSum As Integer

Dim validLuhn As Boolean

Dim intTemp As Integer

strRev = StrReverse(strCCNumber)

Try

For intTemp = 1 To Len(strRev)

strCh = Mid(strRev, intTemp, 1)

intNumber = CInt(strCh)

If intTemp Mod 2 = 0 Then

intNumber = intNumber * 2

If intNumber > 9 Then

intNumber = intNumber - 9

End If

End If

strNumberFinal = strNumberFinal & intNumber

Next intTemp

For intTemp = 1 To Len(strNumberFinal)

intSum = intSum + Mid(strNumberFinal, intTemp, 1)

Next intTemp

If intSum Mod 10 = 0 Then

validLuhn = True

Else

validLuhn = False

End If

Catch

validLuhn = False

End Try

Return validLuhn

End Function

End Class


// Client Class
Dim Client As New SoapClientFormatterSinkProvider

Dim Server As New SoapServerFormatterSinkProvider

Server.TypeFilterLevel = Runtime.Serialization.Formatters.TypeFilterLevel.Full

Dim Ports As IDictionary = New Hashtable

Dim S As String

S = Guid.NewGuid.ToString

Ports("Number") = S

Dim Chann As HttpChannel = New HttpChannel(Ports, Client, Server)

ChannelServices.RegisterChannel(Chann)

Dim objCreditCardComp As CreditCardValidator

RemotingConfiguration.RegisterWellKnownClientType(GetType(CreditCardComp.CreditCardValidator), "HTTP://localhost:8085/MyURI")

objCreditCardComp = New CreditCardValidator

Dim isvalid As Boolean = objCreditCardComp.Validate(TextBox1.Text)

If Not isvalid Then

MessageBox.Show("Credit Card Number is Invalid!")

Else

MessageBox.Show("Credit Card Number is Valid!")

End If


//Server Class

Console.WriteLine("Credit Card Validator Publisher Ver 1.0")

Console.WriteLine("Component Published Successfully!")

Dim Server As New SoapServerFormatterSinkProvider

Dim Client As SoapClientFormatterSinkProvider = Nothing

Server.TypeFilterLevel = Runtime.Serialization.Formatters.TypeFilterLevel.Full

Dim Ports As IDictionary = New Hashtable

Ports.Add("Port", 8085)

Dim channel As HttpChannel = New HttpChannel(Ports, Client, Server)

ChannelServices.RegisterChannel(channel)

Try

RemotingConfiguration.RegisterWellKnownServiceType(GetType(CreditCardComp.CreditCardValidator), "MyURI", WellKnownObjectMode.SingleCall)

Catch ex As RemotingException

Console.WriteLine(ex.Message)

End Try

Console.WriteLine("Press ENTER to exit...")

Console.ReadLine()