2013-01-24 25 views
0

我知道這裏有很多類似的問題,但我的問題並不完全相同,建議的解決方案不適用於我。因此,我創建了名爲「MyApp 1.0」的C#.NET桌面應用程序,但後來將默認命名空間更改爲MyApp。現在,我希望我的應用能夠以各種語言本地化,因此我添加了新的資源文件以保留每種語言的UI字符串,如MyAppUIText.en.resxMyAppUIText.gu.resx等。我還創建了一個使用public static方法的類來從應用程序中任何位置的這些資源中訪問字符串,其代碼如下所示。找不到適合指定文化的任何資源......在本地化的C#.Net桌面應用程序

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Resources; 

namespace MyApp 
{ 
    namespace Utility 
    { 
     class UIText 
     { 
      private static ResourceManager rm = new ResourceManager("MyApp.MyAppUIText", typeof(FormMyAppMain).Assembly); 

      public static string GetString(string key) 
      { 
       return rm.GetString(key, System.Globalization.CultureInfo.CurrentUICulture); 
      } 
     } 
    } 
} 

當我運行我的應用程序,我得到以下運行時錯誤

找不到適合指定區域性或中性文化的任何資源。確保在編譯時「MyApp.MyAppUIText.resources」已正確嵌入或鏈接到程序集「MyApp 1.0」中,或者確保所有需要的附屬程序集均可加載並完全簽名。

但是,字符串正確加載到UI中,但是,窗體設計器顯示與標題To prevent possible data loss before loading the designer, the following errors must be resolved:相同的錯誤。

我在這裏做錯了什麼?

P.S. 我是C#的新手,但我對Java非常熟悉,並且之前曾使用它的properties文件。

回答

0

您已刪除或重命名MyApp.MyAppUIText.resx文件。 確保表單的語言設置爲(默認),更改表單上的某些文本,更改表單的Text屬性將執行此操作。 VS將創建一個新的MyApp.MyAppUIText.resx文件,構建您的解決方案並運行它。

+0

不適合我.... – Kushal

相關問題