gpt4 book ai didi

c# - 可本地化的 WPF 应用程序 - UICulture 设置导致资源问题

转载 作者:行者123 更新时间:2023-11-30 13:41:03 26 4
gpt4 key购买 nike

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

//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 类:

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 指定的设置之间存在某种不匹配,但我不知道如何修复它。

最佳答案

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

// 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")]

关于c# - 可本地化的 WPF 应用程序 - UICulture 设置导致资源问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6079754/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com