繁体   English   中英

XAML 设计未在 Visual Studio 中加载

[英]XAML design not loading in visual studio

我正在尝试在 Visual Studio 中加载 xaml 文件,但它引发了异常,但是当我运行该应用程序时,设计和所有功能都非常好。 例外情况如下:

InvalidCastException: Unable to cast object of type 'System.Windows.Application' to type 'Omnia.PIE.VTA.App'.
   at Omnia.PIE.VTA.MainWindow.get_Instance()
   at Omnia.PIE.VTA.Views.AccountHolderInfo.UserControl_Loaded(Object sender, RoutedEventArgs e)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

提前抱歉,但我是视觉工作室的初学者,花了几个小时后我仍然无法解决它。

我能够解决这个问题。 它与项目缓存有关。 我按照以下步骤解决了这个问题:

  1. 关闭Visual Studio
  2. 删除了.vs,bin和obj文件
  3. 启动VS并清理项目
  4. 重建项目

完成这些步骤后,我可以打开所有.xaml文件。

如果我不理解你的问题,我很抱歉。 听起来你说设计师不工作,但运行它是。

如果是这种情况,Visual Studio无法运行在x64模式下呈现xaml(称为xdescproc I belive)的应用程序。 要解决此问题,请尝试切换到x86。 如果可以,但你不想让x86作为一个选项,你可以尝试配置一个有利于x64的AnyCPU配置,但仍然允许x86(这将意味着在设计模式下它显示x86,这将允许xdescproc运行) 。

就我而言,不知何故,我项目的目标平台已更改为x64 我将其恢复为旧配置,之后 XAML 设计器再次开始工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM