Bug 54928 - Link Assemblies Task Failed with error XA2006
Summary: Link Assemblies Task Failed with error XA2006
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-04-10 11:08 UTC by sandeep.rayat
Modified: 2017-10-04 16:26 UTC (History)
2 users (show)

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

Android Version (12.04 KB, image/png)
2017-04-10 11:08 UTC, sandeep.rayat

Description sandeep.rayat 2017-04-10 11:08:44 UTC
Created attachment 21388 [details]
Android Version

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=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') with scope 'System, Version=, 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?

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 1 Jon Douglas [MSFT] 2017-06-19 19:17:05 UTC
Non-engineering team preliminary quick review

## Specific to one particular project, development computer, or target mobile device?

Specific to Mono Linker behavior with non-available assemblies in a Debug vs. Release configuration

## Includes steps to reproduce the problem and a description of the actual vs. expected behavior?

No steps are included nor a reproduction. We will need a minimal project that demonstrates this issue.

## Considers the relevant log files for the part(s) of the process where something goes wrong (IDE editing, MSBuild building, deploying, launching, attaching the debugger, an in-app error, or something else) and has them attached?
(See https://developer.xamarin.com/guides/cross-platform/troubleshooting/questions/version-logs/ for general reference.)

Yes, provides enough logging of the linker error in question.

## Misc Notes

System.Configuration is not an available assembly in Xamarin.Android:


Thus this assembly is being pulled in by something else and the linker cannot find any reference to this assembly as it's not available.


ConfigurationException on the other hand is found in System.Configuration

## Next Steps

We will need a minimal reproduction. We want to see where the reference to the System.Configuration assembly is coming from. This is typically not a supported assembly in Xamarin.Android.
Comment 2 Jon Douglas [MSFT] 2017-10-04 16:26:27 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!

Note You need to log in before you can comment on or make changes to this bug.