Ticket #11707 (closed defect: obsolete)

Opened 7 years ago

Last modified 4 years ago

IGuestProcess.Read and IDisplay.TakeScreenShotPNGToArray throw exception

Reported by: LeeEll Owned by:
Component: guest control Version: VirtualBox 4.2.12
Keywords: Cc:
Guest type: other Host type: other


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.

Change History

comment:1 Changed 6 years ago by voltagex

Any updates on this? This problem has been around for quite some time. The fix mentioned in no longer works.

comment:2 Changed 6 years ago by klaus

Huh? The forum link you're providing talks about running XP VMs, no trace of any COM API stuff.

So far we have a relatively ugly hack in trunk (not yet included in 4.3 as it needs improving to be a generic solution). It's all about the currently too strict SAFEARRAY type checking, which insists on exact signed/unsigned types, and some API clients (probably some language bindings) are simply sloppy with what they pass.

comment:3 Changed 4 years ago by aeichner

  • Status changed from new to closed
  • Resolution set to obsolete

Please reopen if still relevant with a recent VirtualBox release.

Note: See TracTickets for help on using tickets.
ContactPrivacy policyTerms of Use