Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 可本地化WPF应用程序-UICulture设置导致资源问题_C#_Wpf_Visual Studio_Localization_Currentuiculture - Fatal编程技术网

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

C# 可本地化WPF应用程序-UICulture设置导致资源问题,c#,wpf,visual-studio,localization,currentuiculture,C#,Wpf,Visual Studio,Localization,Currentuiculture,我想创建一个可本地化的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 u

我想创建一个可本地化的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.



以前一切都很顺利。我假设配置的UICulture设置与为MainWindow.xaml指定的UICulture设置之间存在某种不匹配,但我不知道如何修复它。

我也有类似的效果;在AssemblyInfo.cs中,
NeutralResourcesLanguage
属性需要
UltimateResourceAllBackLocation.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")]

一些背景信息来自:

WPF本地化的最佳实践

  • 将AssemblyInfo.*中的
    UltimateResourceCallback
    位置设置为 为回退指定适当的语言(例如,
    [assembly:NeutralResourcesLanguage(“en-US”,
    UltimateResourceCallbackLocation.Satellite)]
  • 如果您决定通过以下方式将源语言包括在主程序集中: 忽略项目文件中的
    标记,设置
    ultimateResourceCallback
    将位置作为主程序集而不是 卫星(例如,
    [assembly:NeutralResourcesLanguage(“en-US”),
    UltimateResourceCallbackLocation.main程序集)]

.

算上我,在部署到两台类似计算机中的一台时出现了一个神秘的错误,因为其中一台具有不同的操作系统语言。现在一切都好了。
<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>
// 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")]