XamlCTask task unexpectedly failed in Xamarin

I am currently having a problem creating my Xamarin.Forms solution. I get the error The "XamlCTask" task failed unexpectedly . I tried looking at the Xamarin and Stacktrace logs, but I cannot find this to be a problem. Any suggestions I can start looking for?

Magazines

 <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 status Error "XamlCTask task" ended unexpectedly. System.ArgumentException: An item with the same key has already been added.

Server stack trace: at System.ThrowHelper.ThrowArgumentException (ExceptionResource resource) in System.Collections.Generic.Dictionary`2.Insert (TKey key, TValue value, Boolean add) at Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor node IElement XmlReader) in Xamarin.Forms.Xaml.XamlParser.ReadNode (XmlReader reader, Boolean nested) in Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor (IElementNode node, XmlReader nested) in Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor (IElementNode node, XmlReader) in Xamarin.Forms.Build.Tasks.XamlCTask.ParseXaml (stream stream, TypeReference typeReference) in Xamarin.Forms.BuileTask. Task ) at Xamarin.Forms.Build.Tasks.XamlCTask.Execute () at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage (IntPtr md, Object [] args, Object server, Object [] & outArgs) in System.Runt ime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage (iMessage MSG)

Exception thrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage (iMessage reqMsg, IMessage retMsg) in System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (MessageData & Int3232), type. 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

+7
xaml xamarin xamarin.forms
source share
10 answers

TL; dr:

disable XamlC on the error page

 [XamlCompilationAttribute (XamlCompilationOptions.Skip)] public partial class MyPageThrowing {} 

or at assembly level

 [assembly:XamlCompilationAttribute (XamlCompilationOptions.Skip)] 

Long story

The problem with the same exception and the same StackTrace was fixed in the next (today) version of xamarin.forms , which should be 2.3.3-pre3 or 2.3.4.

The only way to know for sure is to embed your bad Xaml page here, or better, at http://bugzilla.xamarin.com .

I really urge you to do this. If the problem is not already fixed. Either this is a problem in your Xaml and it requires a better exception, or it is an unsupported case in XamlC and it needs a fix.

+5
source share

First of all, this problem will be raised if the version of xamarin.forms is not compatible with the nudget you pointed to. Therefore, I would like to tell you about these steps and continue.

 Step1: Update Xamarin.Forms version in PCL and all other projects. Step2: Check for matching dependencies with nuget package.ie make sure everywhere the the solution is using the **same** version of the Xamarin.Forms. 

Hope this helps you.

+1
source share

Hopes can be useful to someone else, I had the same error as in the question (... "XamlCTask task" unexpectedly ended. System.ArgumentException: an element with the same key has already been added ...) my problem was caused The ListViewTemplate that contained the DataTemplate into which I put two items: Label and Picker.

Grouping the Label e Picker in a unique element, Frame, inside the DataTemplate, solved my problem.

+1
source share

I have already solved the problem. Since I renamed namespaces, I incorrectly named the namespace alias. I used xmlns:sample.pages="clr-namespace:JustAnotherNamespace" (.) In an alias like this xmlns:sample.pages="clr-namespace:JustAnotherNamespace" . When I deleted the points, the solution was able to build!

0
source share

I had the same problem. A clean or reboot did not help. Now I tried the simulator instead of the device. It worked. Subsequently, I was able to create and run on the device.

Edit:

Now I had a problem a second time. But here it was different. The app no ​​longer compiled. Now it works. This is what I did:

  • Transition to XF 2.3.3.168
  • Go to XF 2.3.3.168 for the specified project
  • Compilation bug fixed (appeared only after update)
0
source share

This happens sometimes if your Xamarin Forms nugets become corrupt. Uninstall and reinstall them.

0
source share

Perhaps you have two instances of Visual Studio to access the same device.

0
source share

in this case, deleting the bin and obj folder seems to work like a charm!

0
source share

I also had this error. In my case, this turned out to be a xaml problem. I have not made any changes to any DLL files or links. I just made some recent haml changes and I suddenly started getting this error. This haml that I wrote caused the problem:

  <StackLayout Grid.Row="4" Orientation="Horizontal" HorizontalOptions="Center" > <StackLayout.Children> <Label Text="Holes" BackgroundColor="White" VerticalOptions="Center"/> <Entry x:Name="entryHoles" BackgroundColor="White" WidthRequest="100"/> </StackLayout.Children> <StackLayout.Children> <Label Text="Par" BackgroundColor="White" VerticalOptions="Center"/> <Entry x:Name="entryPar" BackgroundColor="White" WidthRequest="100"/> </StackLayout.Children> </StackLayout> 

There should be only one StackLayout.Children tag. This is what I switched to in order to clear this error:

  <StackLayout Grid.Row="4" Orientation="Horizontal" HorizontalOptions="Center" > <StackLayout.Children> <Label Text="Holes" BackgroundColor="White" VerticalOptions="Center"/> <Entry x:Name="entryHoles" BackgroundColor="White" WidthRequest="100"/> <Label Text="Par" BackgroundColor="White" VerticalOptions="Center"/> <Entry x:Name="entryPar" BackgroundColor="White" WidthRequest="100"/> </StackLayout.Children> </StackLayout> 

I bet that the optional StackLayout.Children tag triggered this message: "An item with the same key has already been added." If so, it would be great if Microsoft told us what a duplicate element is. I spent a lot of time updating NuGet packages.

0
source share

This error indicates that the versions of the NuGet packages and the version of Xamarin.Forms do not match. Just upgrade the NuGet packages in the project, or remove Xamarin.Forms from the package list, and then add it again.

0
source share

All Articles