The C# wrapper have a pattern which create an object callback without referencing it on linux, so the garbage collector can be called on it and create a crash.
#if (_WIN32 || WINDOWS_UWP)
on_log_message_written_private = on_log_message_written;
IntPtr cb = Marshal.GetFunctionPointerForDelegate(on_log_message_written_private);
linphone_logging_service_cbs_set_log_message_written(nativePtr, cb);
#else
linphone_logging_service_cbs_set_log_message_written(nativePtr, on_log_message_written);
#endif
Adding a reference to the callback as it is done on windows fix the issue.
on_log_message_written_private = on_log_message_written;
#if (_WIN32 || WINDOWS_UWP)
IntPtr cb = Marshal.GetFunctionPointerForDelegate(on_log_message_written_private);
linphone_logging_service_cbs_set_log_message_written(nativePtr, cb);
#else
linphone_logging_service_cbs_set_log_message_written(nativePtr, on_log_message_written_private);
#endif
The fix can't affect windows, but do affects every other platforms. Tested on linux with the .NET Core and ASP.NET 6.0 and 7.0 An automatic test can be added if we decide to test the C# wrapper for now on.