[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mono-devel-list
Subject:    Re: [Mono-dev] ValueTypes and mono_runtime_invoke
From:       Robert Jordan <robertj () gmx ! net>
Date:       2008-05-30 0:12:31
Message-ID: g1ngqi$c5g$1 () ger ! gmane ! org
[Download RAW message or body]

Sebastian Good wrote:
> 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

"I don't pass in NULL the object and parameters" does not make sense
as you must pass NULL in this case.

> 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?

Returning boxed valuetypes is usually working as expected. Please
show some code (C++ and C#).

Robert

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic