VirtualBox

Opened 11 years ago

Closed 8 years ago

#11707 closed defect (obsolete)

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

Description

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);

and

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 (3)

comment:1 by voltagex, 10 years ago

Any updates on this? This problem has been around for quite some time. The fix mentioned in https://forums.virtualbox.org/viewtopic.php?f=34&t=5503 no longer works.

comment:2 by Klaus Espenlaub, 10 years ago

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 by aeichner, 8 years ago

Resolution: obsolete
Status: newclosed

Please reopen if still relevant with a recent VirtualBox release.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use