[Mono-dev] ValueTypes and mono_runtime_invoke

Sebastian Good sebastian at palladiumconsulting.com
Thu May 29 19:54:51 EDT 2008


I have wrapped a function which returns a DateTime and call it using
mono_runtime_invoke. This is a static method, so I don't pass in NULL for
the object and parameters, and get a MonoObject* back. My understanding is
that this MonoObject* should be a boxed DateTime. When I attempt to use this
DateTime (e.g. by calling ToString() on it) it appears to be a clean
MonoObject, but it contains a value very close to the default value for
DateTime, namely "1/1/0001 12:00:04 AM". This suggests it has been lost
somewhere between the underlying function call and the result of
mono_runtime_invoke. In cases of functions which return primitive
ValueTypes, there is no problem, e.g. int marshaled_ret_val =
*reinterpret_cast<int*>(mono_object_unbox(ret_val));

I am happy to carry around a boxed version of the ValueType (DateTime) as I
have to box it to call functions on it anyway through the embedding API. Any
ideas?

Many thanks

Sebastian Good
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080529/b1b7645c/attachment.html 


More information about the Mono-devel-list mailing list