Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remoting Error while returning collection

Status
Not open for further replies.

vbtest5

IS-IT--Management
Nov 16, 2002
37
0
0
IN
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
 
Can you post your attempt at using a collection and show where it errors?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top