本文介绍了“XamlCTask"Xamarin 中的任务意外失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在构建 Xamarin.Forms 解决方案时遇到问题.我收到XamlCTask"任务意外失败的错误.我尝试查看 Xamarin 日志和 Stacktrace,但似乎找不到问题所在.我可以从哪里开始寻找任何建议?

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?

日志

<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>

堆栈跟踪

严重性代码描述项目文件行抑制状态错误XamlCTask"任务意外失败.System.ArgumentException:具有相同键的项目已被已添加.

服务器堆栈跟踪:在System.ThrowHelper.ThrowArgumentException(ExceptionResource 资源)在 System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue值,布尔加)在Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode 节点,XmlReader 阅读器)在Xamarin.Forms.Xaml.XamlParser.ReadNode(XmlReader 阅读器,布尔值嵌套)在Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode 节点,XmlReader 阅读器)在Xamarin.Forms.Xaml.XamlParser.ReadNode(XmlReader 阅读器,布尔值嵌套)在Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode 节点,XmlReader 阅读器)在Xamarin.Forms.Build.Tasks.XamlCTask.ParseXaml(流流,TypeReference typeReference) 在Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 在Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 在System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtrmd,对象[] args,对象服务器,对象[]&outArgs) 在System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage味)

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)

在 [0] 处重新抛出异常:在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessagereqMsg, IMessage retMsg) atSystem.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData,Int32 类型)在 Microsoft.Build.Framework.ITask.Execute()
在Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()在Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() XXXXXXX.XXXXXX.XXXXXX

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

推荐答案

tl;dr:

在失败的页面上禁用 XamlC

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

或在程序集级别

[assembly:XamlCompilationAttribute (XamlCompilationOptions.Skip)]

长话

xamarin.forms 的问题应该是 2.3.3-pre3 或 2.3.4.

Long Story

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.

确定知道的唯一方法是将失败的 Xaml 页面粘贴到这里,或者甚至更好,粘贴到 http://bugzilla.xamarin.com.

The only way to know for sure would be to paste your failing Xaml page here, or even better, on http://bugzilla.xamarin.com.

我真的鼓励你这样做.如果问题尚未解决.要么是 Xaml 中的问题,需要抛出更好的异常,要么是 XamlC 中不受支持的情况,这需要修复.

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.

这篇关于“XamlCTask"Xamarin 中的任务意外失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 01:51