WPF XAML 解析异常发生错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21400026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF XAML Parse Exception occured Error?
提问by TheSpy
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
x:Class="AFICController.EULA"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:res="clr-namespace:AFICController.Resources"
Title="{x:Static res:Strings.WizardWelcomeWindow_Title}"
Width="800"
Height="600"
WindowStartupLocation="CenterScreen"
Icon="/AFICController;Component/Resources/Images/att_icon.ico"
ResizeMode="NoResize">
I am working on a C# WPF Applcation i am implementing it using MVVM .My Application shows splash screen at first which appears fine but after that i want EULA(End user license agreement) Window when i try to execute it shows an exception as "XAML Parse Exception "Provide value on 'System.Windows.Markup.StaticExtension' threw an exception" by locating towards the above code.
我正在开发一个 C# WPF 应用程序,我正在使用 MVVM 实现它。我的应用程序首先显示启动画面,这看起来不错,但之后我想要 EULA(最终用户许可协议)窗口,当我尝试执行它时显示异常为“XAML通过定位到上述代码,解析异常“在 'System.Windows.Markup.StaticExtension' 上提供值引发异常”。
Following is my C# code from where i am calling EULA..Please help me as i have tried my all ways in removing this exception.?
以下是我调用 EULA 的 C# 代码。请帮助我,因为我已经尝试了所有方法来删除此异常。?
class App : Application
{
[STAThread()]
static void Main()
{
Splasher.Splash = new SplashScreen();
Splasher.ShowSplash();
Mouse.OverrideCursor = null;
for (int i = 0; i < 5000; i++)
{
Thread.Sleep(1);
}
Splasher.CloseSplash();
new App();
}
/// <summary>
///
/// </summary>
public App()
{
App.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"\Resources\Dictionary\ATTColors.xaml", UriKind.Relative) });
App.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"\Resources\Dictionary\AppButton.xaml", UriKind.Relative) });
Console.WriteLine("EULA Opened");
StartupUri = new System.Uri("EULA.xaml", UriKind.Relative);
//StartupUri = new System.Uri("View/WizardDialog.xaml", UriKind.Relative);
Run();
}
回答by jnovo
Given your error:
鉴于您的错误:
"XAML Parse Exception "Provide value on 'System.Windows.Markup.StaticExtension' threw an exception"
“XAML 解析异常”在“System.Windows.Markup.StaticExtension”上提供值引发异常”
I think your problems lies in this line:
我认为你的问题在于这一行:
Title="{x:Static res:Strings.WizardWelcomeWindow_Title}"
which is where the StaticExtensionis used.
这StaticExtension是使用的地方。
Make sure that your Strings.resxis public by going to its properties and checking that Custom Tool is set to PublicResXFileCodeGenerator(and not ResXFileCodeGenerator, which is the default) - you can either directly edit it there or through the Access Modifiedcombobox in the designer when you open the resources file.
Strings.resx通过转到其属性并检查自定义工具是否设置为PublicResXFileCodeGenerator(而不是ResXFileCodeGenerator默认设置)来确保您是公开的- 您可以在那里直接编辑它,也可以Access Modified在打开资源文件时通过设计器中的组合框进行编辑。

