Ticket #11707 (new defect)
IGuestProcess.Read and IDisplay.TakeScreenShotPNGToArray throw exception
|Reported by:||LeeEll||Owned by:|
I am using the VirtualBox 4.2.12 COM API with C# NET 4.0 and Visual Studio 2010, host OS either Win7-x64 or WinXP-x86, guest OS WinXP-x86.
API functions IGuestProcess.Read and IDisplay.TakeScreenShotPNGToArray have System.Array as return type signature. This return type compiles but causes the following SafeArrayTypeMismatchException marshaling exception at runtime:
Specified array was not of the expected type.
at System.StubHelpers.MngdSafeArrayMarshaler.ConvertSpaceToManaged(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome)
at VirtualBox.IGuestProcess.Read(UInt32 aHandle, UInt32 aToRead, UInt32 aTimeoutMS)
Calls that cause this exception are:
System.Array output = GuestProcess.Read(0, 2000, 5000);
Console.Display.TakeScreenShotPNGToArray(0, 640, 480);
I have tried var as return type. That compiles but throws the same exception. I have also tried byte and a lot of other array types and a cast to System.Array to make it compile, but still get the same exception at runtime.
It looks as if the API is seriously broken for functions that have array return types.