Requested Service Not Found -
01-04-2006
, 08:28 AM
Hi,
I'm pretty new to the whole .NET concept. I'm trying to make a simpl
VB.NET application that will tell me the current time. But whenever
try to call any remote methods I get an error telling me that th
"Requested Service Was not Found". Can anyone let me know what thi
means and how I can fix it?
I've included some of the code that I'm using:
Code
-------------------
Public Interface MailInterface
Function GetTime() As String
End Interface
-------------------
Code
-------------------
Public Class MailImpl
Inherits MarshalByRefObject
Implements MailInterface.MailInterface
Public Function GetTime() As String Implements MailInterface.MailInterface.GetTime
Return "The time is: " & DateTime.Now.ToString
End Function
End Class
-------------------
Code
-------------------
'This is in the Server application, , creating channels etc.
Dim oServerProv As BinaryServerFormatterSinkProvider = New BinaryServerFormatterSinkProvider
Dim oClientProv As BinaryClientFormatterSinkProvider = New BinaryClientFormatterSinkProvider
Dim oProps As IDictionary = New Hashtable
oServerProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilter Level.Full
oProps("port") = "1234"
oProps("name") = "Mail"
oChannel = New TcpChannel(oProps, oClientProv, oServerProv)
ChannelServices.RegisterChannel(oChannel, False)
RemotingConfiguration.RegisterWellKnownServiceType (GetType(MailImpl.MailImpl), "Mail", WellKnownObjectMode.Singleton)
Try
oServer = CType(Activator.GetObject(GetType(MailImpl.MailImp l), "tcp://localhost:1234/Mail"), MailInterface.MailInterface)
If oServer Is Nothing Then MsgBox("Server Not Found")
Catch ex As Exception
Debug.WriteLine(ex.Message)
MsgBox(ex.Message)
End Try
-------------------
Code
-------------------
' This is in the client application, creating channels etc.
oServerProv = New BinaryServerFormatterSinkProvider
oClientProv = New BinaryClientFormatterSinkProvider
oServerProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilter Level.Full
oProps("port") = iPortNum
oProps("name") = "Mail"
oChannel = New TcpChannel(oProps, oClientProv, oServerProv)
ChannelServices.RegisterChannel(oChannel, False)
Try
oServer = CType(Activator.GetObject(GetType(MailInterface.Ma ilInterface), "tcp://localhost:" & iPortNum & "/Mail"), MailInterface.MailInterface)
If oServer Is Nothing Then
MsgBox("Server Not Found")
Return False
Else
Return True
End If
Catch ex As Exception
MsgBox(ex.Message)
Return False
End Try
-------------------
Code
-------------------
' Actually calling the remote method from the client
Console.WriteLine(oServer.GetTime)
-------------------
Any help will be much appreciated. Thanks very much,
dlarkin7
--
dlarkin7 |