Bug 11365 - Linker removes a referenced user assembly in Release mode (resulting in a "type not found" exception)
Summary: Linker removes a referenced user assembly in Release mode (resulting in a "ty...
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.7.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Dominique Louis
URL:
Depends on:
Blocks:
 
Reported: 2013-03-22 18:16 UTC by softlion
Modified: 2013-05-24 10:56 UTC (History)
4 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description softlion 2013-03-22 18:16:41 UTC
version 4.7.00000 (alpha 1)

Linking setting : SDK Assemblies Only (default in Release mode)
Comment 1 Radek Doulik 2013-05-06 05:12:12 UTC
I wasn't able to replicate with version 4.7.4.

Please reopen if it still doesn't work for you with current version.
Comment 2 softlion 2013-05-10 16:48:27 UTC
It still does not work with version xamarin.android.4.7.04014 on my project A.
Though it works ok on my project B.

Both projects use PCL (portable libraries) and targets android 4.0

In porject A I also use java binding projects and "normal" assemblies.

This is the only linker error i have on project A:

20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Collections.Generic.Collection`1.get_Item(Int32 index)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Cecil.Mdb.MdbReader.ReadLocalVariables(MethodEntry entry, MethodBody body, Scope[] scopes)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Cecil.Mdb.MdbReader.Read(MethodBody body, InstructionMapper mapper)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Cecil.Cil.CodeReader.ReadMethodBody()
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Cecil.MethodDefinition.<get_Body>b__2(MethodDefinition method, MetadataReader reader)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Cecil.MethodDefinition.get_Body()
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.Process()
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Mono.Linker.Pipeline.Process(LinkContext context)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
20>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(824,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()
========== Build: 19 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Comment 3 softlion 2013-05-10 16:54:57 UTC
When built with Xamarin Studio instead of VS2012, project A has this issue which blocks the build process. Maybe it is related.


Exécution : mv System.Xml.Serialization.Droid.dll System.Xml.Serialization.dll
---------------------- Done ----------------------

Failed to execute custom command 'mv': Le fichier spécifié est introuvable
Build canceled.
Comment 4 softlion 2013-05-10 17:05:38 UTC
Well my "comment 3" could be removed. I fixed the project file so this error won't appear anymore.

But the linker error is still there.
Comment 5 softlion 2013-05-10 17:31:14 UTC
I retried with Xamarin Studio, and in solution A there is a project which does not ocmpile. The same project compiles fine on VS2012. This project is not used by the 
android app. And i was able to package a version of solution A correctly with Xamarin Studio.

So the linker issue is caused by a .resx file in a subproject used by a web app project. All these projects, including the android app project, are in the same solution A.

Solution A
+ Android app project
+ Web project (.net 4.5)
+ C# lib project (.net 4.5)
++ /Resources/mvc.resx
+++ /mvc.Designer.cs

The build action of mvc.resx is set to "Embedded Resource"
And the custom tool to PublicResXFileCodeGenerator

As these resources are not required, i set the build action to "none" and this fixes the compilation and linking issue in Xamarin Studio.

But not in VS2012 with the same solution !!
Comment 6 softlion 2013-05-10 17:43:45 UTC
Ah, the "project/create android package" command in Xamarin Studio seems to work (no error), but it generates a non working apk package, which size is suspiciously very small (2Mb).
Comment 7 softlion 2013-05-10 17:49:50 UTC
Ach, i'm writing things but it's late and i wrote crap.

Well there is the same linker error in release mode in xamarin studio (debug mode compiles fine).

This "bug" only goes away when setting the LinkMode to "None" (in release mode).
Comment 8 Jonathan Pryor 2013-05-22 16:43:46 UTC
> Both projects use PCL (portable libraries) and targets android 4.0

PCL support is still in-progress. Does it still fail if you don't use PCL libraries?

Can you provide a complete sample which reproduces the issue?
Comment 9 softlion 2013-05-22 17:48:42 UTC
Another customer has the same problem :

http://forums.xamarin.com/discussion/3292/alpha-4-same-problem-with-linker-in-vs2012#latest
Comment 10 Olivier Ansquer 2013-05-24 02:45:32 UTC
I have the same problem. My project doesn't use PCL.
Comment 11 Jonathan Pryor 2013-05-24 08:39:01 UTC
softlion: Comment #2 isn't a "assembly removed by linker", it's "the linker dies on certain debug symbols", which should be fixed in 4.6.4 (stable) and 4.7.5 (alpha, which doesn't work, doh!).

Is your project referencing Mono.Android.Support.v4.dll (or .v13) by any chance?
Comment 12 softlion 2013-05-24 10:08:12 UTC
4.7.5 (alpha, which doesn't work, doh!)

Well it works. See my thread in the prerelease forum for fixes.
Comment 13 Jonathan Pryor 2013-05-24 10:56:49 UTC
Closing as fixed as there doesn't appear to be an open issue anymore.