[Mono-list] Embedded Mono: calling c# method from c does not work...
Ipo
ipo at penttinen.org
Tue Oct 21 03:47:04 EDT 2008
Hello, i'm beginner with c and mono. Now i have a "little" problem. I can not
get resurt from my assembly. Here is my Code:
c#
#################################################################
using System;
namespace MySpace
{
class MyClass
{
int val = 5;
string str = "hello";
MyClass ()
{
Console.WriteLine ("while Constructor Val", val);
Console.WriteLine ("While In ctor str is: {0}", str);
}
MyClass (int v, byte[] array)
{
Console.WriteLine ("Constructor: In ctor (int, byte[]) got value: {0},
array len: {1}", v, array.Length);
}
public string Testi (ref int v, ref string s)
{
Console.WriteLine ("In Values () param v is {0}", v);
Console.WriteLine ("In Values () params s is: {0}", s);
string paluu = "Hello";
return paluu;
}
static void Main()
{
}
}
}
#################################################################
c:
val = 100;
str2 = mono_string_new (domain, "param2");
args [0] = &val;
args [1] = &str2;
MonoObject *result = mono_runtime_invoke (my_method, obj, args, NULL);
MonoString *strReturn = (MonoString *)mono_object_unbox(result);
str = mono_string_to_utf8(strReturn);
printf ("result from method is: %s\n", str);
#################################################################
Compiling goes ok. but when i run c-code:
** ERROR **: file object.c: line 4097 (mono_object_unbox): assertion failed:
(obj->vtable->klass->valuetype)
#################################################################
I got integer values Ok.
I dont only now how to typecast object with mono_object_unbox to string.
Actually i am more interested to call from c-language C# method who returns
IList.
yours.
Ipo
--
View this message in context: http://www.nabble.com/Embedded-Mono%3A-calling-c--method-from-c-does-not-work...-tp20085126p20085126.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list