Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As far as I can tell, the default calling convention for Mono on Unix platforms is <code>cdecl</code>. Which presumably matches your C++ code. So I guess that's not the problem. Worth double-checking though. Perhaps specify the calling convention explicitly in your pinvoke.</p> <p>I don't understand why you are using <code>UnmanagedType.Struct</code> for the return value. So far as I can tell that is not correct. On .net that would result in the struct being marshalled as a <code>VARIANT</code> which is absolutely not what you want. I'm not sure whether <code>UnmanagedType.Struct</code> has any meaning for Mono pinvoke on Linux, but in any case it should not be present so you should remove it.</p> <p>Nor is there any need to name the entry point. So I'd simplify the p/invoke.</p> <pre><code>[DllImport("somelib.so")] public static extern some_struct some_function(); </code></pre> <p>The other obvious potential mismatch would be between your native and managed struct definitions. You said:</p> <blockquote> <p>As you can see, there are no parameters that need marshaling, so the problem isn't with data that is being passed in.</p> </blockquote> <p>That's true, but what about the return value being passed out. That needs marshalling too, and you've got to get it right. Without being able to see definitions of your struct types (both native and managed), we're in no position to judge. If you cannot show them here, then you'll have to check that they match.</p> <p>Finally, it is conceivable the your compiler and the pinvoke marshaller assume a different ABI for struct return values. That is always a grey area. I would always recommend simple types as return values and return your struct as an out parameter.</p> <p>If I had to bet, I'd say that the problem lies in the struct definitions, which sadly you have not shown.</p> <hr> <p><strong>Update</strong></p> <p>Your question edit indicates that you have problems with a function that has <code>void</code> return type. In which case the only sane conclusion is that the problem is in your native code and not in the p/invoke. To track this down further, you'll need to look at the native code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload