xaml - 添加 Pivot 和其他 Microsoft.Phone 控件时,Visual Studio 2012 XAML UI 设计器引发异常

标签 xaml visual-studio-2012 designer windows-phone-8

每当我向 Microsoft.Phone 命名空间中的 Windows Phone 8 应用程序添加任何控件(Pivot、Panorama 等)时​​,XAML 设计器都会抛出:

Error HRESULT E_FAIL has been returned from a call to a COM component.

堆栈跟踪似乎有所不同,这是在文档大纲中选择全景图后的跟踪:

at Microsoft.Phone.Controls.Design.PanoramaItemAdorner.Activate(ModelItem item)
   at Microsoft.Windows.Design.Interaction.AdornerProvider.InvokeActivate(EditingContext context, ModelItem item)
   at MS.Internal.Features.AdornerProviderFeatureConnector.FeatureProvidersAdded(ModelItem item, IEnumerable`1 extensions)
   at Microsoft.Windows.Design.Policies.PolicyDrivenFeatureConnector`1.OnPolicyItemsChanged(Object sender, PolicyItemsChangedEventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at Microsoft.Windows.Design.Policies.ItemPolicy.OnPolicyItemsChanged(PolicyItemsChangedEventArgs e)
   at Microsoft.Windows.Design.Policies.SelectionPolicy.OnSelectionChanged(Selection newSelection)
   at Microsoft.Windows.Design.ContextItemManager.SubscribeProxy`1.SubscribeContext(ContextItem item)
   at Microsoft.Windows.Design.SubscribeContextCallback.Invoke(ContextItem item)
   at Microsoft.Windows.Design.EditingContext.DefaultContextItemManager.OnItemChanged(ContextItem item)
   at Microsoft.Windows.Design.EditingContext.DefaultContextItemManager.SetValue(ContextItem value)
   at Microsoft.Expression.DesignSurface.ViewModel.Extensibility.ExtensibilityManager.SetSelection(Selection selection)
   at Microsoft.Expression.DesignSurface.ViewModel.Extensibility.ExtensibilityManager.OnViewModelEarlySceneUpdatePhase(Object sender, SceneUpdatePhaseEventArgs args)
   at Microsoft.Expression.DesignSurface.ViewModel.SceneUpdatePhaseEventHandler.Invoke(Object sender, SceneUpdatePhaseEventArgs args)
   at Microsoft.Expression.DesignSurface.ViewModel.SceneViewModel.FireEarlySceneUpdatePhase(SceneUpdatePhaseEventArgs args)
   at Microsoft.Expression.DesignSurface.Pipeline.SceneViewUpdateScheduleTask.UpdateEarly()
   at Microsoft.Expression.Utility.Scheduler.ScheduleTask.Update()
   at Microsoft.Expression.Utility.Scheduler.SchedulingService.DispatchTasksAtPriority(DispatcherPriority priority)
   at Microsoft.Expression.Utility.Scheduler.SchedulingService.DispatcherToken.Dispatch(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

如果文件加载了控件,则堆栈跟踪如下所示:

at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.Collection_InsertValue[T](PresentationFrameworkCollection`1 collection, UInt32 index, CValue value)
   at MS.Internal.XcpImports.Collection_InsertDependencyObject[T](PresentationFrameworkCollection`1 collection, UInt32 index, DependencyObject value)
   at System.Windows.PresentationFrameworkCollection`1.InsertDependencyObject(Int32 index, DependencyObject value)
   at System.Windows.Controls.UIElementCollection.InsertInternal(Int32 index, UIElement value

同一个 .xaml 文件在 Blend 中工作得很好,一旦删除控件,设计器就会重新开始工作。

我已尝试卸载/修复 Windows Phone 8 SDK、Visual Studio 以及 Silverlight SDK 和运行时。

还有其他想法吗?

最佳答案

我遇到了同样的问题,并尝试了许多论坛上讨论的每个答案。

最后,我删除了“解决方案”文件 (.sln),而不是项目,然后将所有项目添加回我的新解决方案中。

使用:VisualStudio Express 2012

步骤:

  • 在 Windows 资源管理器中删除您的项目所在的解决方案 (.sln) 文件。
  • 在 VisualStudio 中打开主项目文件 (.csproj)。
  • 然后将所有其他“现有项目”添加回您的新解决方案中。

现在效果很好...希望有帮助。

关于xaml - 添加 Pivot 和其他 Microsoft.Phone 控件时,Visual Studio 2012 XAML UI 设计器引发异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13595390/

相关文章:

c# - C# XAMARIN.FORMS 中的 BorderBrush

c# - Windows Phone 7 中的列表框滚动到结尾

c# - 发布时有没有办法调用自定义代码?

c++ - VS2012 中的 strtof() 在哪里?

c# - 在设计模式下进行编辑时 designer.vb 文件中的自定义代码消失

c# 从 Designer 中隐藏函数

WPF设计器异常; "An item with the same key had already been added"

wpf - 使用 ItemTemplate 在 ListBoxItems 构建上添加事件

c# - WPF自定义控件库图片资源

javascript - 找出哪些 Javascript 方法从未被调用