Troubleshooting Exceptions: System.Runtime.InteropServices.SafeArrayRankMismatchException

 

A SafeArrayRankMismatchException exception is thrown when the rank of an incoming SAFEARRAY does not match the rank specified in the managed signature.

Associated Tips

  • Make sure your array has the required number of dimensions.
    Because the rank and bounds of a safe array cannot be determined from the type library, the rank is assumed to equal 1, and the lower bound is assumed to equal 0. The rank and bounds must be defined in the managed signature produced by the Tlbimp.exe (Type Library Importer).

See Also

SafeArrayRankMismatchException
How to: Use the Exception Assistant
Default Marshaling for Arrays
Arrays in Visual Basic