Microsoft KB Archive/189911

= PRB: REDIMENSION an Array Passed by Reference in DLL Fails =

Article ID: 189911

Article Last Modified on 8/17/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q189911



SYMPTOMS
Attempting to REDIMENSION an array that has been passed by reference from within a Visual FoxPro COM object will result in the following error message:

OLE IDispatch exception code 302 from Visual FoxPro for Windows: Data type mismatch...



CAUSE
An array that has been passed by reference to a Visual FoxPro COM object cannot be redimensioned from within the COM object.



RESOLUTION
The array must be redimensioned in the client before passing the reference to the Visual FoxPro COM object.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Create a new project named MyDLL.  Add a new program to the project containing the following code: DEFINE Class VFPArray As Custom OlePublic PROCEDURE GetArray(aRetVal) LOCAL x           FOR x = 1 To 50 DIMENSION aRetVal[x] aRetVal[x] = x           NEXT x         ENDPROC ENDDEFINE  Build the project into a COM DLL.  Run the following code from Visual FoxPro: ox = CreateObject("MyDLL.VFPArray") DIMENSION myarray[1] ComArray(ox,11) ox.GetArray(@myarray) 

NOTE: The above mentioned error message will occur when calling the GetArray method in the COM object.

Keywords: kbprb KB189911

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.