Bug 16610 - OSX Linker removes mscorlib
Summary: OSX Linker removes mscorlib
Status: RESOLVED DUPLICATE of bug 16485
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Other ()
Version: 1.6.19
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Aaron Bockover [MSFT]
Depends on:
Reported: 2013-12-04 19:55 UTC by James
Modified: 2013-12-05 17:36 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description James 2013-12-04 19:55:21 UTC
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" ?>
    <assembly fullname="mscorlib">
        <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.
Comment 1 Sebastien Pouliot 2013-12-05 17:36:47 UTC
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 ***