Silverlight项目中的“CompileXaml”任务意外失败

时间:2017-03-03 09:34:32

标签: .net visual-studio silverlight

我正在使用Visual Studio 2015 Update3。

我的解决方案包含.NET Framework 4项目和silverlight项目。 当我尝试构建silverlight项目时, 我得到这样的错误。

我读过这篇文章 Cannot find System.Xaml? 并且发现我应该以.Net 3.5为目标,但我该如何处理Silverlight项目呢?

"CompileXaml" task failed unexpectedly.
System.IO.FileNotFoundException: file or assembly 'XamlServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'XamlServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 'XamlServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Server stack trace: 
   Microsoft.Silverlight.Build.Tasks.CompileXaml.GenerateCode(ITaskItem item, Boolean isApplication)
   Microsoft.Silverlight.Build.Tasks.CompileXaml.Execute()
    System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]: 
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   Microsoft.Build.Framework.ITask.Execute()
   Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

1 个答案:

答案 0 :(得分:0)

因为silverlight是独立平台,所以无法在Silverlight项目中更改.net平台。您只能将Silverlight版本从4更改为5.但是您可以在Microsoft文档命名空间中阅读System.Xaml在silverlight(https://msdn.microsoft.com/en-us/library/system.xaml(v=vs.95).aspx)中非常有限。

也许您应该考虑在服务器端项目中编写代码,您可以选择.NET framework&gt; = 4(.NET 3.5还没有此DLL),并且命名空间System.Xaml更复杂({{3 }})。与服务器通信Silverlight您可以使用RIA服务。