VirtualBox

Ticket #11707 (new defect)

Opened 12 months ago

Last modified 3 days ago

IGuestProcess.Read and IDisplay.TakeScreenShotPNGToArray throw exception

Reported by: LeeEll Owned by:
Priority: critical 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

comment:1 Changed 3 days ago by voltagex

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 Changed 3 days 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.

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use