Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / December 2004

Tip: Looking for answers? Try searching our database.

COMException "Memory is locked" on COM method call

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
steverino - 30 Nov 2004 08:37 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.