Bug 14316 - Android App not working when linker enabled.
Summary: Android App not working when linker enabled.
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.8.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Alex Rønne Petersen
: 14545 ()
Depends on:
Reported: 2013-08-29 03:23 UTC by Dmitry Upovalov
Modified: 2013-11-07 17:00 UTC (History)
7 users (show)

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

Exception (4.76 KB, text/plain)
2013-08-29 03:23 UTC, Dmitry Upovalov
linker.xml (233 bytes, text/xml)
2013-10-28 01:50 UTC, Dmitry Upovalov

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 Dmitry Upovalov 2013-08-29 03:23:21 UTC
Created attachment 4738 [details]

Xamarin Studio 4.0.9 (build 12).
Android application which uses class, inherited from System.Data.Services.Client.DataServiceContext.

Application works fine when build without linker.
As soon as linker enabled we observe an exception (attached).

In the constructor of System.Data.Services.Client.TypeSystem reflection is used. Linker removes unused methods and properties of System.String, System.DateTime, System.Math (reflection is applied to these classes), so DataServiceContext becomes unusable.

We can fix it by using custom linker rules:
    <assembly fullname="mscorlib">
        <type fullname="System.String"/>
        <type fullname="System.DateTime"/>
        <type fullname="System.Math"/>

But seems, that it's a bug of linker. These code parts should not be removed by linker in case of TypeSystem is used by application.
Comment 1 Jonathan Pryor 2013-08-29 11:15:18 UTC
@Alex: We should add custom linker rules for when System.Data.Services.Client.dll is referenced so that the appropriate types are preserved.
Comment 2 Alex Rønne Petersen 2013-09-01 07:01:01 UTC
This *should* be fixed (I've added a linker descriptor file that preserves the needed methods), but I need a sample to verify to be 100% sure.
Comment 3 Jonathan Pryor 2013-09-09 12:26:14 UTC
*** Bug 14545 has been marked as a duplicate of this bug. ***
Comment 4 andy_from_fl 2013-10-27 19:29:49 UTC
I'm in production and not ready to upgrade just yet. I'd love to know where to put that <linker> xml element referenced above for a quick fix until I can upgrade.
Comment 5 Dmitry Upovalov 2013-10-28 01:50:55 UTC
Created attachment 5249 [details]
Comment 6 Dmitry Upovalov 2013-10-28 01:52:17 UTC
For andy_from_fl@yahoo.com:
If I understand your question correctly, then you should put linker.xml file (I had attached it) into Properties folder of your project (for Android Project). Is the same location as for AndroidManifest.xml file. Once done, choose "LinkDescription" as build action for this file (Right mouse click on file -> Build Action).
Comment 7 andy_from_fl 2013-10-28 19:48:52 UTC
Shoot, I included the file you attached in the properties folder alongside androidmanifest.xml, included it in the project, made its build action LinkDescription, and tried both values for copy to output directory- same exact error, surely because of the wcf web services reference.

Thanks anyway for your help, I appreciate it.
Comment 8 andy_from_fl 2013-11-07 17:00:15 UTC
Nevermind- it turns out that I was using the free edition and was unable to use linker files, but VS never told me it was just ignoring my commands.

This worked perfectly- thanks very much.