2011-05-21 37 views
2

我想创建一个本地化的WPF应用程序。我已经按照AssemblyInfo.cs文件中的注释说明:可本地化的WPF应用程序 - UICulture设置导致资源问题

//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指定的设置不匹配,但我不知道如何解决它。

回答

9

我有类似的效果;在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")] 
+0

绝对救星,感谢这个:) – Lukazoid 2013-01-02 10:21:03

+0

算我一份,有esoterical错误部署到两个类似的机器之一,因为他们中的一个有不同的OS语言。现在情况很好。 – heltonbiker 2014-04-10 16:36:08