Callback back into C# with arguments crashes from Hololens DLL

I have developed a plugin that uses callbacks to call back into C#. I am trying to get this plugin to work on Hololens, and the Hololens emulator crashes at the end of the call to these callbacks. It has also been reported that this behavior happens on the Hololens as well: HoloLens Callbacks with Native Library - Questions & Answers - Unity Discussions

I am currently using Unity 5.6.2f1, but it also crashes in the new 2017.1.

Does anyone know how to avoid this crash? Callbacks work when there are no arguments. If I convert these arguments to IntPtr (e.g., for strings), the string can still be read, but it still crashes.

I submitted a bug with an isolated project, but I thought that this forum could have a larger audience.

Any help would be much appreciated!

Thanks,

Blaine

The issue in that post you mentioned is the fact that the calling convention on native and managed doesn’t match. C++ defaults to __cdecl, while C# defaults to __stdcall. The solution is to annotate the callback pointers with “__stdcall” on the native side.

that works, thanks!