Hi,
I am using Remoting with TCP. When I return the string it works. But when I try to return a collection, it gives error. Can anyone help me how to return a collection of objects?
Below is the code:
Imports System.IO
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Data.SqlClient
Imports System.Net
Module Module1
Sub main()
Dim ch As New TcpChannel(8099)
ChannelServices.RegisterChannel(ch)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(PersonalInfo), "ServiceUri", WellKnownObjectMode.Singleton)
Console.WriteLine("In Main")
Console.ReadLine()
End Sub
End Module
Public Class BenefitType
Dim BenefitID As Integer
Dim BenefitName As String
Public Sub New()
BenefitID = 0
BenefitName = ""
End Sub
Public Sub New(ByVal BenID As Integer, ByVal name As String)
BenefitID = BenID
BenefitName = name
End Sub
End Class
<Serializable()> _
Public Class PersonalInfo
Inherits MarshalByRefObject
Public Function GetName() As String
Dim count As Integer
Dim col As Collection
For count = 1 To 2
Dim objBenefitType As BenefitType
objBenefitType = New BenefitType(count, "Medical" & CStr(count))
col.Add(objBenefitType)
Next
Return "test"
End Function
End Class
Here when I return the string "test", it works.
Regards,
Vilas
I am using Remoting with TCP. When I return the string it works. But when I try to return a collection, it gives error. Can anyone help me how to return a collection of objects?
Below is the code:
Imports System.IO
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Data.SqlClient
Imports System.Net
Module Module1
Sub main()
Dim ch As New TcpChannel(8099)
ChannelServices.RegisterChannel(ch)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(PersonalInfo), "ServiceUri", WellKnownObjectMode.Singleton)
Console.WriteLine("In Main")
Console.ReadLine()
End Sub
End Module
Public Class BenefitType
Dim BenefitID As Integer
Dim BenefitName As String
Public Sub New()
BenefitID = 0
BenefitName = ""
End Sub
Public Sub New(ByVal BenID As Integer, ByVal name As String)
BenefitID = BenID
BenefitName = name
End Sub
End Class
<Serializable()> _
Public Class PersonalInfo
Inherits MarshalByRefObject
Public Function GetName() As String
Dim count As Integer
Dim col As Collection
For count = 1 To 2
Dim objBenefitType As BenefitType
objBenefitType = New BenefitType(count, "Medical" & CStr(count))
col.Add(objBenefitType)
Next
Return "test"
End Function
End Class
Here when I return the string "test", it works.
Regards,
Vilas