I am currently having a problem building my Xamarin.Forms solution. I'm getting an error of The "XamlCTask" task failed unexpectedly
. I tried looking at the Xamarin logs and Stacktrace but I can't seem to find what's the issue. Any suggestions where I can start looking?
Logs
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>0</EventID>
<Type>3</Type>
<SubType Name="Warning">0</SubType>
<Level>4</Level>
<TimeCreated SystemTime="2016-10-11T10:45:07.4999078Z" />
<Source Name="Xamarin.VisualStudio.Android.Designer.MonoAndroidDesignerService" />
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
<Execution ProcessName="devenv" ProcessID="19260" ThreadID="1" />
<Channel />
<Computer>XXXXXX</Computer>
</System>
<ApplicationData>An unexpected error occurred trying to initialize Android Designer.</ApplicationData>
</E2ETraceEvent>
Stack Trace
Severity Code Description Project File Line Suppression State Error The "XamlCTask" task failed unexpectedly. System.ArgumentException: An item with the same key has already been added.
Server stack trace: at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode node, XmlReader reader) at Xamarin.Forms.Xaml.XamlParser.ReadNode(XmlReader reader, Boolean nested) at Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode node, XmlReader reader) at Xamarin.Forms.Xaml.XamlParser.ReadNode(XmlReader reader, Boolean nested) at Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode node, XmlReader reader) at Xamarin.Forms.Build.Tasks.XamlCTask.ParseXaml(Stream stream, TypeReference typeReference) at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Build.Framework.ITask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() XXXXXXX.XXXXXX.XXXXXX
disable XamlC
on the failing Page
[XamlCompilationAttribute (XamlCompilationOptions.Skip)]
public partial class MyPageThrowing {}
or at the Assembly level
[assembly:XamlCompilationAttribute (XamlCompilationOptions.Skip)]
An issue throwing the same exception and the same StackTrace had been fixed in the next (to date) version of xamarin.forms which should be 2.3.3-pre3 or 2.3.4.
The only way to know for sure would be to paste your failing Xaml page here, or even better, on http://bugzilla.xamarin.com.
I really encourage you to do so. If the issue is not fixed already. Either it's an issue in your Xaml and this needs a better exception being thrown, or it's an unsupported case in XamlC, and this require a fix.
First of all this issue will be raised when xamarin.forms version is not compatible with the nuget that you are pointed to. So i'd like to tell you these steps and go ahead.
Step1: Update Xamarin.Forms version in PCL and all other projects.
Step2: Check for matching dependencies with nuget package.i.e make sure everywhere the the solution is using the **same** version of the Xamarin.Forms.
Hope this will helps you.
Hope could be usefull to someone else, I had the same error shown in the question (..."XamlCTask" task failed unexpectedly. System.ArgumentException: An item with the same key has already been added...), my issue was caused by a ListViewTemplate, which contained a DataTemplate, in which I putted two elements, a Label and a Picker.
Grouping Label e Picker in a unique element, a Frame, inside the DataTemplate, solved my issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With