【发布时间】:2015-01-15 10:50:18
【问题描述】:
MonoObject * pException = NULL;
// this method will cause an exception in c#, something like null exception
MonoString * pResult = (MonoString*) mono_runtime_invoke(g_pGetMethod, NULL, monoargs, &pException);
/* debugging with gdb:
(gdb) n
Program received signal SIGPWR, Power fail/restart.
then this program stopped.
*/
char * szResult = NULL;
if(pException == NULL)
{
szResult = mono_string_to_utf8(pResult);
} else
{
//MonoString * pMsg = mono_object_to_string_ex(pException, NULL);
//szResult = mono_string_to_utf8(pMsg);
szResult = "Mono throwed an Exception!";
}
我正在尝试像上面那样捕获 MonoException,
有什么我弄错了吗?
g_pGetMethod 是一个静态函数 btw,如果没有抛出异常,这些代码可以正常工作
【问题讨论】:
标签: c exception-handling mono embedding