Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Customer is using a native library via P/Invoke that contains functions that accept string parameters in UTF-32 encoding, which is not supported by the CharSet property of the DllImport attribute. To work around this they created a custom marshaller class that implements System.Runtime.InteropServices.ICustomMarshaler.
When compiling for a real device the following error is displayed:
* Assertion at ../../../../../mono/mono/metadata/marshal.c:5886, condition `cleanup_native' not met
Looking at the mono source code, this seems to be a problem resolving the methods of the ICustomMarshaler interface.
To address it they tried to create a linker configuration file to solve this, as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<type fullname="System.Runtime.InteropServices.ICustomMarshaler" preserve="all" />
...then I added the following to the "Additional mtouch arguments" in the project settings:
However this seems to have no effect. In the end creating a dummy class that does nothing but invoke the methods of ICustomMarshaler, and adding the [Preserve] attribute to it to ensure it was not remove by the linker appears to be a work around.
I verified that `mmp` (the OSX tool for Mac apps) is correct.
mtouch itself was fixed last week.
An XML worked fine for me (in fact that's how it's fixed). Impossible to tell without a test case (maybe the extra option was not copied to every configuration?). Please re-open if you can get a test case.
*** This bug has been marked as a duplicate of bug 16485 ***