Bug 53385 - Link Assemblies Task Failed with error XA2006
Summary: Link Assemblies Task Failed with error XA2006
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: Linker ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: 15.6
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2017-03-16 10:12 UTC by sandeep.rayat
Modified: 2017-11-30 12:13 UTC (History)
3 users (show)

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


Attachments
Android Version (12.04 KB, image/png)
2017-03-16 10:12 UTC, sandeep.rayat
Details


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 ANSWERED

Description sandeep.rayat 2017-03-16 10:12:00 UTC
Created attachment 20377 [details]
Android Version

Severity	Code	Description	Project	File	Line	Suppression State
Error		The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'System.Configuration.ConfigurationException' (defined in assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') with scope 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Configuration.ConfigurationException
   at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
   at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
   at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
   at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
   at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
   at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.MarkStep.Initialize()
   at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
   at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   --- End of inner exception stack trace ---
   at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()	TeaTotal.Droid			





Getting this error in Release build only. Seems to build find in debug mode but seems to be a linker problem? 

I have updated the android versions(see attachment) so doesn't seem to be that. 

Any ideas?
Comment 1 sandeep.rayat 2017-03-27 12:02:07 UTC
Any thoughts on this issue?
Comment 2 sandeep.rayat 2017-03-28 09:30:25 UTC
03-28 09:22:13.445 F/monodroid-assembly( 2966): Could not load assembly 'System.Configuration' during startup registration.
03-28 09:22:13.445 F/monodroid-assembly( 2966): This might be due to an invalid debug installation.
03-28 09:22:13.445 F/monodroid-assembly( 2966): A common cause is to 'adb install' the app directly instead of doing from the IDE.
Comment 3 nitesh.luharuka@gmail.com 2017-11-14 12:15:48 UTC
Any update to this issue> This occurs when System.Configuration dll has been added to .Android & .iOS projects for Xamarin.Forms
Comment 4 Radek Doulik 2017-11-14 15:13:55 UTC
Could you please attach a project, which reproduces the issue?
Comment 5 nitesh.luharuka@gmail.com 2017-11-14 19:00:20 UTC
I have checked this out and if I set the Linking property to "None" under Linking Properties for Android project, it works and the issue is not replicated. However, the app size increase manifolds.
Comment 6 Jonathan Pryor 2017-11-27 20:00:37 UTC
> This occurs when System.Configuration dll has been added to .Android & .iOS projects for Xamarin.Forms

`System.Configuration.dll` is *not* an assembly that is provided with either Xamarin.Android or Xamarin.iOS, and is not an assembly that should be used on either Xamarin.Android or Xamarin.iOS.

https://developer.xamarin.com/guides/cross-platform/advanced/available-assemblies/

https://developer.xamarin.com/guides/ios/advanced_topics/limitations/
> Xamarin.iOS does not include System.Configuration, so it is not possible
> to use external XML files to configure the behavior of the runtime.


> error XA2006: Could not resolve reference to 'System.Configuration.ConfigurationException'
> (defined in assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
> with scope 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

You have an assembly which contains a type reference to `System.Configuration.ConfigurationException`. Please recompile that assembly as a Xamarin.Android Library assembly or .NET Standard 2.0 assembly so that it no longer references `System.Configuraiton.dll`.
Comment 7 nitesh.luharuka@gmail.com 2017-11-30 12:13:12 UTC
Here's my scenario - I have a Models project that contains the EF code & Models and further used by my API project and Xamarin projects. The Models project has access to System.Configuration dll for accessing data from the database. As soon as I reference the Models dll to my Xamarin app, it fails. What should be a workaround to for this?