【问题标题】:The "XamlCTask" task failed unexpectedly. What to do?“XamlCTask”任务意外失败。该怎么办?
【发布时间】:2017-11-17 20:34:10
【问题描述】:

我收到此错误:

“XamlCTask”任务意外失败。 System.ArgumentException: 已添加具有相同键的项。

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.Xaml.XamlParser.ReadNode(XmlReader reader, Boolean nested)
   at Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode node, XmlReader reader)
   at Xamarin.Forms.Xaml.XamlParser.ParseXaml(RootNode rootNode, XmlReader reader)
   at Xamarin.Forms.Build.Tasks.XamlTask.ParseXaml(Stream stream, TypeReference typeReference)
   at Xamarin.Forms.Build.Tasks.XamlCTask.Execute(IList`1& thrownExceptions)
   at Xamarin.Forms.Build.Tasks.XamlTask.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.<ExecuteInstantiatedTask>d__26.MoveNext() 

我知道这是说该项目是重复的,但我用 Total Commander 扫描了整个项目,但没有找到任何重复的文件。

【问题讨论】:

标签: c# xamarin xamarin.forms


【解决方案1】:

您的 XAML 页面中可能只是有一个错误。 “已添加具有相同密钥的项目。”可能是一些重复的属性。

【讨论】:

  • 没有看到代码...几乎可以肯定它是某种重复的样式或资源。
  • 是的,App.xaml 中的资源条目重复也有这样的错误
  • 有没有办法自动查找重复代码?我尝试使用 Visual Studio 2017 分析函数,但我没有代码克隆函数的分析解决方案。谢谢!
  • 不确定,如果我希望您使用源代码管理,我会做的就是还原最近所做的更改直到问题消失,然后开始应用更改直到问题出现,找出原因.. 叹息
  • 我解决了。我在项目 %TEMP% 文件夹中找到了问题文件。感谢您的帮助!
【解决方案2】:

整合您的 nuGet 包并确保所有 Xamarin.Forms 引用项目都使用相同的 Xamarin.Forms 版本。之后清空包文件夹,清理并重建您的解决方案。

【讨论】:

    【解决方案3】:

    通常在编译 xaml 代码时发生错误。检查最近添加的代码。

    【讨论】:

      猜你喜欢
      • 2017-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      • 2018-01-02
      相关资源
      最近更新 更多