ïHi,
I think I got it. I think I have to marshal in this manner :
[StructLayout(LayoutKind.Sequential)]
public class DomainInfo
{
private byte state;
[MarshalAs(UnmanagedType.SysUInt)]
public UIntPtr maxMem;
[MarshalAs(UnmanagedType.SysUInt)]
public UIntPtr memory;
public ushort nrVirtCpu;
[MarshalAs(UnmanagedType.SysUInt)]
public UIntPtr cpuTime;
public DomainState State { get { return (DomainState)state; } }
}
And I also have to set the target of the LibvirtBindings project to x86. Why
? The compilation of libvirt under mingwin produce a 32bits binary, so I
MUST marshal libvirt with a 32bits schema. That doesn't break compatibility
with 64bits project using bindings, and this allow the usage of the
attribute [MarshalAs(Unamanged.SysUint)]. This attribute specify the target
schema for bindings at runtime. In this way, under 64bits systems, it takes
ulong on 8 bytes, and on 4 bytes under 32bits.
This make the bindings work under Windows/mono(32bits, as the mono
exxcutable is in 32bits, even if my system is 64bits), works also under
Windows/.Net(64bits) and works under Ubuntu/Mono(64 bits).
Any suggestion ?
Regards,
Arnaud
--------------------------------------------------
From: "Justin Clift" <jclift@xxxxxxxxxx>
Sent: Saturday, October 30, 2010 1:39 AM
To: <arnaud.champion@xxxxxxxxxx>
Cc: "Matthias Bolte" <matthias.bolte@xxxxxxxxxxxxxx>; "Daniel P. Berrange"
<berrange@xxxxxxxxxx>; <libvir-list@xxxxxxxxxx>
Subject: Re: virDomainInfo marshalling prolem
On 10/30/2010 01:48 AM, arnaud.champion@xxxxxxxxxx wrote:
There is an unmanaged type to specify when marshaling this :
UnamanagedType.SysInt or UnmanagedType.SysUInt, which are 64b or 32bits
aware. But the problem under windows : libvirt is compiled thru mingwin
so the dll is in 32bits and even if windows is in 64bits, I have to make
bindings over 32bits (I'm not sure my english make things clear when I
explain)
Yeah, that's clear. Using mingwin is causing the bindings to be 32-bit,
regardless of whether the Windows OS is 32-bit or 64-bit.
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list