WPF:安装在 XP 上时 WPF 应用程序中出现 XamlParseException
我有一个 WPF 应用程序,它在 vista/7 上运行得很好,但在 Windows XP 上它会抛出 System.Windows.Markup.XamlParse 错误。
我将 Visual studio 2010 与 .NET 4.0、Telerik Q2 2011 Controls 和 DevExpress Control 2011 一起使用。
有关异常的详细信息:
Application: CVServer.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException
Stack:
at System.Windows.Markup.XamlReader.RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext)
at System.Windows.Application.LoadComponent(System.Uri, Boolean)
at System.Windows.Application.DoStartup()
at System.Windows.Application.<.ctor>b__1(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
at System.Threading.ExecutionContext.runTryCode(System.Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at System.Windows.Application.Run(System.Windows.Window)
at System.Windows.Application.Run()
at Procesta.CvServer.App.Main()
更新 1:
我正在从静态资源文件应用样式
更新 2:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib">
<!-- Resource dictionary entries should be defined here. -->
<RadialGradientBrush x:Key="Background" GradientOrigin="-0.01,1.01" RadiusY="0.52">
<GradientStop Color="#FF62BAFB"/>
<GradientStop Color="#FF0070DA" Offset="0.479"/>
<GradientStop Color="#FF00499F" Offset="1"/>
</RadialGradientBrush>
<FontFamily x:Key="ButtonFontFamily">Segoe UI</FontFamily>
<SolidColorBrush x:Key="TextBlockForeground" Color="Black"/>
<System:Double x:Key="ButtonFontSize">13.333</System:Double>
<System:Double x:Key="TextFontSize">14.667</System:Double>
<LinearGradientBrush x:Key="TextBoxBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFD0D8E8" Offset="0.006"/>
<GradientStop Color="#FFE5E9F1" Offset="0.124"/>
<GradientStop Color="#FFFEFEFE" Offset="0.972"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ImageButtonForeground" Color="Black"/>
<SolidColorBrush x:Key="ImageButtonToolTipBorder" Color="#FFA30909"/>
<SolidColorBrush x:Key="ImageButtonToolTipBackground" Color="#A18C8C93"/>
<System:Double x:Key="ImageButtonFontSize">16</System:Double>
<FontFamily x:Key="ImageButtonFontFamily">Adobe Kaiti Std R</FontFamily>
</ResourceDictionary>
应用这些资源,如下所示
Background="{DynamicResource Background}"
I have a WPF application which runs perfectly fine on vista/7 but on Windows XP it chucks up the System.Windows.Markup.XamlParse error.
I use Visual studio 2010 with .NET 4.0, Telerik Q2 2011 Controls and DevExpress Control 2011.
Detail about exception:
Application: CVServer.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException
Stack:
at System.Windows.Markup.XamlReader.RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext)
at System.Windows.Application.LoadComponent(System.Uri, Boolean)
at System.Windows.Application.DoStartup()
at System.Windows.Application.<.ctor>b__1(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
at System.Threading.ExecutionContext.runTryCode(System.Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at System.Windows.Application.Run(System.Windows.Window)
at System.Windows.Application.Run()
at Procesta.CvServer.App.Main()
Update 1:
I am applying styling from a static resource file
Update 2:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib">
<!-- Resource dictionary entries should be defined here. -->
<RadialGradientBrush x:Key="Background" GradientOrigin="-0.01,1.01" RadiusY="0.52">
<GradientStop Color="#FF62BAFB"/>
<GradientStop Color="#FF0070DA" Offset="0.479"/>
<GradientStop Color="#FF00499F" Offset="1"/>
</RadialGradientBrush>
<FontFamily x:Key="ButtonFontFamily">Segoe UI</FontFamily>
<SolidColorBrush x:Key="TextBlockForeground" Color="Black"/>
<System:Double x:Key="ButtonFontSize">13.333</System:Double>
<System:Double x:Key="TextFontSize">14.667</System:Double>
<LinearGradientBrush x:Key="TextBoxBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFD0D8E8" Offset="0.006"/>
<GradientStop Color="#FFE5E9F1" Offset="0.124"/>
<GradientStop Color="#FFFEFEFE" Offset="0.972"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ImageButtonForeground" Color="Black"/>
<SolidColorBrush x:Key="ImageButtonToolTipBorder" Color="#FFA30909"/>
<SolidColorBrush x:Key="ImageButtonToolTipBackground" Color="#A18C8C93"/>
<System:Double x:Key="ImageButtonFontSize">16</System:Double>
<FontFamily x:Key="ImageButtonFontFamily">Adobe Kaiti Std R</FontFamily>
</ResourceDictionary>
Apply those Resource like this
Background="{DynamicResource Background}"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能的问题可能是 Segoe UI 字体的使用。 XP 中未安装此字体。
Possible problem can be the usage of Segoe UI Font. This font is not installed with XP.