Skip to content

Instantly share code, notes, and snippets.

@7Hazard
Created August 16, 2017 02:18
Show Gist options
  • Save 7Hazard/c9a9342f51861c093c347037e1477e2d to your computer and use it in GitHub Desktop.
Save 7Hazard/c9a9342f51861c093c347037e1477e2d to your computer and use it in GitHub Desktop.
void Invoke(MonoDomain* domain, MonoMethod* method, MonoObject* obj, void** args, bool threaded) {
if (threaded) {
mono_thread_attach(domain);
}
MonoObject** exc;
try {
mono_runtime_invoke(method, obj, args, exc);
}
catch (MonoObject* obj)
{
printf("Catch MonoObject* stub\n");
MonoString* StringOutput = mono_object_to_string(obj, NULL);
char* output = mono_string_to_utf8(StringOutput);
printf("Our ToString is this:\n%s\n", output);
}
catch (MonoObject** obj)
{
printf("Catch MonoObject** stub\n");
MonoString* StringOutput = mono_object_to_string(*obj, NULL);
char* output = mono_string_to_utf8(StringOutput);
printf("Our ToString is this:\n%s\n", output);
}
catch (void** obj)
{
printf("Catch void** stub\n");
MonoString* StringOutput = mono_object_to_string((MonoObject*)*obj, NULL);
char* output = mono_string_to_utf8(StringOutput);
printf("Our ToString is this:\n%s\n", output);
}
catch (void* obj)
{
printf("Catch void* stub\n");
MonoString* StringOutput = mono_object_to_string((MonoObject*)obj, NULL);
char* output = mono_string_to_utf8(StringOutput);
printf("Our ToString is this:\n%s\n", output);
}
catch (...)
{
printf("Catch all stub\n");
MonoString* StringOutput = mono_object_to_string(*exc, NULL);
char* output = mono_string_to_utf8(StringOutput);
printf("Our ToString is this:\n%s\n", output);
}
//HasException(exc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment