[Mono-list] Problem with DateTime class from C code
federico.omoto at gmail.com
Sun Oct 24 13:06:14 EDT 2010
Robert, thank you again for your answer!
Ok, here's my code, I've tested it on Mono 2.6.4 Linux x86_64 (Fedora 13)
and on Mono 2.8 Windows XP 32bit (replacing g_free() with a mono_free()
int main(int argc, char* argv)
domain = mono_jit_init (argv);
class = mono_class_from_name(mono_get_corlib(), "System",
object = mono_object_new(domain, class);
method = mono_class_get_method_from_name(class, "ToString", 0);
string = (MonoString*)mono_runtime_invoke(method, object, NULL,
pointer = mono_string_to_utf8(string);
As you said, sometimes I get the correct string, but if you execute it many
times you'll see it returning different strings (in my case ranging from
"1/1/0001 12:00:00 AM" to "1/1/0001 12:00:03 AM").
Thank you in advance,
On Sun, Oct 24, 2010 at 9:32 AM, Robert Jordan <robertj at gmx.net> wrote:
> On 23.10.2010 19:18, Fede wrote:
> > Hi Robert, thank you for your answer!
> > I've tried calling the default ctor using mono_runtime_object_init() on
> > DateTime instance but I get an assertion:
> > ERROR:object.c:95:mono_runtime_object_init: assertion failed: (method)
> > Stacktrace:
> Yes, my bad. DateTime does not have an explicit default ctor
> because it's a value type. Hence the assertion.
> Your code is correct as far I can tell from just looking at it.
> A small test case of mine also returns the correct string
> on both 2-6 and 2-8 Mono versions.
> Please post something compilable and don't forget to mention the
> Mono version and the platform.
> Mono-list maillist - Mono-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-list