可本地化的WPF应用程序-UICulture设置导致资源问题 [英] Localizable WPF Application - UICulture settings lead to Resource problems

查看:126
本文介绍了可本地化的WPF应用程序-UICulture设置导致资源问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个可本地化的WPF应用程序.我已经按照AssemblyInfo.cs文件的注释中的说明进行操作:

I want to create aa localizable WPF Application. I've followed the instructions in the comments of the AssemblyInfo.cs file:

//In order to begin building localizable applications, set 
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>.  For example, if you are using US english
//in your source files, set the <UICulture> to en-US.  Then uncomment
//the NeutralResourceLanguage attribute below.  Update the "en-US" in
//the line below to match the UICulture setting in the project file.

完成此操作后,我的应用程序不再启动.我正在使用自定义的App类:

After I've done this, my application isn't starting any more. I'm using a custom App class:

namespace Namespace
{
    public partial class App : Application
    {
        [STAThread()]
        [SecurityPermission(SecurityAction.LinkDemand)]
        public static void Main()
        {
            var app = new App();

            app.InitializeComponent();
            app.Run();
        }


        [DebuggerNonUserCode()]
        public void InitializeComponent()
        {
            this.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
        }
    }
}

<ns:App
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ns="clr-namespace:Namespace">

</ns:App>

之前一切正常.我认为在配置的UICulture设置和为MainWindow.xaml指定的设置之间存在某种不匹配,但我不知道如何解决.

Everything has worked fine before. I assume there's some kind of mismatch between the configured UICulture settings and that one specified for MainWindow.xaml, but I don't know how to fix it.

推荐答案

我有类似的效果;在AssemblyInfo.cs中,NeutralResourcesLanguage属性需要UltimateResourceFallbackLocation.Satellite参数:

I had a similar effect; in the AssemblyInfo.cs, the NeutralResourcesLanguage attribute needed the UltimateResourceFallbackLocation.Satellite parameter:

// Uncommenting the following line --> OK
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
// Uncommenting the following line --> IOException: Cannot locate resource 'app.xaml'.
// [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
// Uncommenting the following line --> IOException: Cannot locate resource 'app.xaml'.
// [assembly: NeutralResourcesLanguage("en-US")]

这篇关于可本地化的WPF应用程序-UICulture设置导致资源问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆