[Mono-list] Unbox a C# object after invoke?

efontana eric at fontanas.net
Fri Feb 24 19:47:05 UTC 2012


Is this possible?

In my C# class I have the following Object that I want to return
from a method that I called via 

[StructLayout(LayoutKind.Sequential)]
public struct ComplexResults
{
  public int x;
  public int y;
  public string value;
}

I have a C# method that I'm calling:

public ComplexResults MyMethod()
{
    ComplexResults r = new ComplexResults();
    r.x = 100;
    r.y = 200;
    r.value = "hello world";
}


--------- C++

struct ComplexResults
{
  int x;
  int y;
  char* str;
} 

MonoObject* result = mono_runtime_invoke(method, instance, params,
&exception);

I want to be able to unbox the MonoObject* result into a C++ ComplexResults?

When I called 

// The mono_object_unbox goes Boom, "Application caused the runtime to do
bad things..."
void* unboxed = mono_object_unbox(mresult);

ComplexResults datap = * (ComplexResults*)unboxed;







--
View this message in context: http://mono.1490590.n4.nabble.com/Unbox-a-C-object-after-invoke-tp4418445p4418445.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list