[Mono-dev] ** ERROR **: Type System.DateTime which is passed to unmanaged code must have a StructLayout attribute aborting...
Robert Jordan
robertj at gmx.net
Sat Jul 11 18:05:14 EDT 2009
Darrek wrote:
> I get this message when trying to run a project in Mono while using a COM
> dll. It errors whenever the constructor is called. Is there any way to get
> around this?
Mono does not support DateTime marshaling for COM interop. The only way
to fix this is to change the signature from DateTime to double and
use DateTime's ToOADate() and FromOADate() members:
Declaration:
from
void SomeMethod(DateTime dt)
to
void SomeMethod(double dt)
Call site:
from
foo.SomeMethod (someDateTime);
to
foo.SomeMethod (someDateTime.ToOADate());
Robert
More information about the Mono-devel-list
mailing list