【问题标题】:XamlParseException when debugging WPF application with Visual Studio 2015使用 Visual Studio 2015 调试 WPF 应用程序时出现 XamlParseException
【发布时间】:2015-12-15 10:31:26
【问题描述】:

我正在开发一个曾经使用 VS 2012 进行调试的 WPF 应用程序。 自从我切换到 Visual Studio 2015 后,我无法再对其进行调试。在运行时我得到 System.Windows.Markup.XamlParseException 并且应用程序崩溃。 需要注意的是,编译的可执行文件在通过双击其图标启动时可以正确运行。我什至可以在 VS 2015 中调试它,方法是在启动后附加进程。

在我的应用程序中,我使用了 xceed.wpf.toolkit。

例外是:

System.Windows.Markup.XamlParseException occurred
  HResult=-2146233087
  LineNumber=58
  LinePosition=15
  Message='Initialization of 'Xceed.Wpf.Toolkit.BusyIndicator' threw an exception.' Line number '58' and line position '15'.
  Source=PresentationFramework
  StackTrace:
       at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at [...].InitializeComponent()
  InnerException: 
       HResult=-2146233088
       LineNumber=0
       LinePosition=0
       Message=Initialization of 'Xceed.Wpf.Toolkit.Core.VersionResourceDictionary' threw an exception.
       Source=System.Xaml
       StackTrace:
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)
            at System.Xaml.XamlObjectWriter.Logic_EndInit(ObjectWriterContext ctx)
            at System.Xaml.XamlObjectWriter.WriteEndObject()
            at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
            at System.Windows.SystemResources.ResourceDictionaries.LoadDictionary(Assembly assembly, String assemblyName, String resourceName, Boolean isTraceEnabled)
            at System.Windows.SystemResources.ResourceDictionaries.LoadThemedDictionary(Boolean isTraceEnabled)
            at System.Windows.SystemResources.FindDictionaryResource(Object key, Type typeKey, ResourceKey resourceKey, Boolean isTraceEnabled, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, Boolean& canCache)
            at System.Windows.SystemResources.FindResourceInternal(Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
            at System.Windows.StyleHelper.GetThemeStyle(FrameworkElement fe, FrameworkContentElement fce)
            at System.Windows.FrameworkElement.UpdateThemeStyleProperty()
            at System.Windows.FrameworkElement.OnInitialized(EventArgs e)
            at System.Windows.FrameworkElement.TryFireInitialized()
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)
       InnerException: 
            HResult=-2146232800
            Message=Cannot locate resource 'xceed.wpf.toolkit;v2.1.0.0;themes/xceed.wpf.toolkit;v2.1.0.0;component/themes/aero/brushes_normalcolor.xaml'.
            Source=PresentationFramework
            StackTrace:
                 at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
                 at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
                 at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
                 at System.IO.Packaging.PackWebResponse.get_ContentType()
                 at MS.Internal.WpfWebRequestHelper.GetContentType(WebResponse response)
                 at MS.Internal.WpfWebRequestHelper.GetResponseStream(WebRequest request, ContentType& contentType)
                 at System.Windows.ResourceDictionary.set_Source(Uri value)
                 at Xceed.Wpf.Toolkit.Core.VersionResourceDictionary.System.ComponentModel.ISupportInitialize.EndInit()
                 at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)
            InnerException: 

另请注意,所涉及的组件 Xceed.Wpf.Toolkit.dll(在正确版本 v2.1.0.0 中)存在于输出目录中,靠近应用程序的编译可执行文件。

有什么建议可以让应用程序使用 VS 2015 集成调试器工作?

谢谢!

【问题讨论】:

  • 注意:我用 ILSpy 打开了 xceed.wpf.toolkit.dll 组件,我可以确认它确实包含源 'xceed.wpf.toolkit;v2.1.0.0;themes/xceed。 wpf.toolkit;v2.1.0.0;component/themes/aero/brushes_normalcolor.xaml'

标签: wpf debugging visual-studio-2015


【解决方案1】:

您可能需要检查this

并使用pack:... 语法。

原来 Toolkit 中存在一个问题,它只会在 VS2015 中出错,而在以前的版本中不会出错。 仍然需要了解最新版本和以前版本的 VS 之间的差异,但至少这个补丁有效。

【讨论】:

    【解决方案2】:

    我禁用了

    调试 |一般 |为 XAML 启用 UI 调试工具

    选项,一切又开始工作了。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-16
    • 1970-01-01
    • 2013-04-07
    相关资源
    最近更新 更多