2011-05-21 65 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