PRB: REDIMENSION an Array Passed by Reference in DLL Fails (189911)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 6.0

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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new project named MyDLL.
  2. 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
    							
  3. Build the project into a COM DLL.
  4. 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.

Modification Type:MajorLast Reviewed:8/17/1999
Keywords:kbprb KB189911