Re: [Mono-list] How to pass an object as ref or out

2014-04-17 Thread Robert Jordan
On 17.04.2014 06:26, carmack2000 wrote: Hi Robert, Thanks for your tips but I still don't understand how to unbox a ref-type. It looks mono_object_unbox only can handle valuetype, not ref-type. So could you please write more lines of code of implementation for an example for this void

Re: [Mono-list] How to pass an object as ref or out

2014-04-17 Thread carmack2000
After I followed your code I got this error: Unhandled exception at 0x100b8c87 in MonoScriptingTest.exe: 0xC005: Access violation reading location 0x. I'll look into this. You said 'This is no better than the former non-ref version.' If I want to use ref-object to return values

Re: [Mono-list] How to pass an object as ref or out

2014-04-17 Thread Robert Jordan
On 17.04.2014 16:55, carmack2000 wrote: After I followed your code I got this error: Unhandled exception at 0x100b8c87 in MonoScriptingTest.exe: 0xC005: Access violation reading location 0x. I'll look into this. You said 'This is no better than the former non-ref version.' If I want

Re: [Mono-list] How to pass an object as ref or out

2014-04-17 Thread Robert Jordan
On 17.04.2014 18:33, Robert Jordan wrote: On 17.04.2014 16:55, carmack2000 wrote: After I followed your code I got this error: Unhandled exception at 0x100b8c87 in MonoScriptingTest.exe: 0xC005: Access violation reading location 0x. I'll look into this. You said 'This is no better

Re: [Mono-list] How to pass an object as ref or out

2014-04-17 Thread carmack2000
IT WORKS ! Thank you so much Robert ! -- View this message in context: http://mono.1490590.n4.nabble.com/How-to-pass-an-object-as-ref-or-out-tp4662539p4662547.html Sent from the Mono - General mailing list archive at Nabble.com. ___ Mono-list

[Mono-list] How to pass an object as ref or out

2014-04-16 Thread carmack2000
I use mono_object_unbox to get an object instance (Vector2) passed from C# to C++. C++ __declspec(dllexport) void SetPosition(MonoString* ms, MonoObject* mo) { Vector2 pos = *(Vector2*)mono_object_unbox(mo); } C# [MethodImplAttribute(MethodImplOptions.InternalCall)] public static extern

Re: [Mono-list] How to pass an object as ref or out

2014-04-16 Thread Robert Jordan
On 16.04.2014 22:31, carmack2000 wrote: I use mono_object_unbox to get an object instance (Vector2) passed from C# to C++. C++ __declspec(dllexport) void SetPosition(MonoString* ms, MonoObject* mo) { Vector2 pos = *(Vector2*)mono_object_unbox(mo); } C#

Re: [Mono-list] How to pass an object as ref or out

2014-04-16 Thread carmack2000
Hi Robert, Thanks for your tips but I still don't understand how to unbox a ref-type. It looks mono_object_unbox only can handle valuetype, not ref-type. So could you please write more lines of code of implementation for an example for this void SetPosition(MonoString* ms, MonoObject** mo) ?