Convert PVarArray to Enum array

Hello, I’m trying to convert a PV array to an enumeration array using the example code that RemObject provided. But I have a SafeArrayRankMismatchException on the C # side

function MarketStatusDtoArrayAsSafeArray(Arr: ArrayOfMarketStatusDto): PVarArray;
var
  pvData: PByteArray;
  Bounds: TVarArrayBoundArray;
begin
   Bounds[0].LowBound:=0;
   Bounds[0].ElementCount:=Length(Arr);

   Result := SafeArrayCreate(varByte, 1, Bounds);
   SafeArrayAccessData(Result, Pointer(pvData));
   Move(Arr[0], pvData[0], Length(Arr));
end;

Please provide a testcase.
In questions like this one it is way too easy to overlook something (either in question or in the answer) without a testcase