dotnet interop:
I have a VB6 collection class that does not always return the correct number
of items when enumerated using a c# front end. However the enumeration only
fails in a release version of the exe. If the project is debugged in Visual
Studio or a debug version of the exe is made the enumeration always works.
The collection class’s structure is
Private m_colItem As Collection
Public Property Get Items() As Collection
Set Items = m_colItem
End Property
Public Property Get NewEnum() As IUnknown
Set NewEnum = m_colItem.[_NewEnum]
End Property
Public Function Load(Optional vWhere, Optional vOrderBy, Optional
bLoadChildren As Boolean) As Boolean
Dim rs As Recordset
Dim oCalculationRule As CUCalculationRule
Dim oDB As CDDataServices
Set oDB = CreateObject("dl.CDDataServices")
'Get all matching records.
If oDB.SelectAll(rs, "CalculationRule", vWhere, vOrderBy) Then
Set m_colItem = New Collection
'Work through the recordset.
While Not rs.EOF
'Create a new object and fill it from the recordset.
Set oCalculationRule = New CUCalculationRule
Call oCalculationRule.PopulateFromRecordset(rs)
'Add the object and add it to the collection.
m_colItem.Add oCalculationRule, CStr(oCalculationRule.IUUserService_ID)
rs.MoveNext
Wend
Load = True
End If
End Function
Private Sub Class_Initialize()
Set m_colItem = New Collection
End Sub
The collection is enumerated in c# using a foreach loop
foreach(CUCalculationRule oSchemeClass in oCalculationRuleList)
{
….
}
oCalculationRuleList is the interop wrapper for the collection class.
The architecture of the application is: UI layer written in c# (.NET 1.1),
VB6 business objects layer, VB6 COM+ data access layer and SQL Server 2000
database. Client OS is Windows 2000 and the COM+ components are hosted by a
Windows Server 2003. The collection class is part of the business objects
layer.
If you have any idea what is causing this or have experienced a similar
problem please let me know.
Thanks in advance, Patrick