Hello:
I am having a marshalling problem between VB.NET 1.1 and CDO from Crystal
Reports 8.5. The AddRows
generates a COMException that I don't understand. This is supposed to be
default marshalling
from what I can figure out; Object to ByVal Variant
The code snippet is as follows:
cdoObj =
DirectCast(CreateObject("CrystalDataObject.CrystalComObject"),CrystalDataObject.CrystalComObject)
cdoObj.AddField( "orderqty", vbInteger)
cdoObj.AddField( "stockno", vbString)
cdoObj.AddField( "productname", vbString)
cdoObj.AddField( "size", vbString)
cdoObj.AddField( "unitprice", vbCurrency)
cdoObj.AddField( "extprice", vbCurrency )
Dim aRows(detail.Count - 1,5) As Object
For I = 0 To detail.Count - 1
aRows(I, 0) = CLng(detail(I).selectSingleNode("quantity").InnerText)
aRows(I, 1) = detail(I).selectSingleNode("stockno").InnerText
aRows(I, 2) = detail(I).selectSingleNode("productname").InnerText
aRows(I, 3) = detail(I).selectSingleNode("size").InnerText
aRows(I, 4) = CDbl(detail(I).selectSingleNode("unitprice").InnerText)
aRows(I, 5) = CDbl(detail(I).selectSingleNode("extprice").InnerText)
Next I
===> cdoObj.AddRows(aRows) <===== throws COMException
throws COMException error DISP_E_ARRAYISLOCKED "Memory is Locked"
IL from the Interop.Cdo32.dll is:
.method public hidebysig newslot virtual
instance void AddRows([in] object marshal( struct) RowData)
runtime managed internalcall
{
.custom instance void
[mscorlib]System.Runtime.InteropServices.DispIdAttribute::.ctor(int32) = ( 01
00 02 00 00 00 00 00 )
.override CrystalDataObject.ICrystalDataObject::AddRows
} // end of method CrystalComObjectClass::AddRows
IDL for the COM call is:
HRESULT AddRows([in] VARIANT RowData);
Any insight would be greatly appreciated as this is hanging up my project.
thanks
stevyn
steverino - 03 Dec 2004 01:59 GMT
Problem Fixed:
The Exception message did not point to the real problem!
The problem was caused by a data type mismatch between the
data types of the fields being defined in "AddField" and
the data types of the data being added in the AddRows.
The mismatch was on vbInteger vs CLng()
and
vbCurrency vs. CDbl()
This code was originally imported from a VB6 application.
ttfn
> Hello:
>
[quoted text clipped - 52 lines]
> thanks
> stevyn