我想在WinForms應用程序中使用衛星程序集進行本地化。目錄結構如下:本地化衛星組件
- 斌
- 的Program.exe
- 德
- Program.resources.dll
在程序中。這個代碼在執行方法:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");
Application.Run(new Form());
我查了FUSLOGVW.exe輸出:
*** Assembly Binder Log Entry (5/30/2012 @ 5:19:37 PM) *** The operation failed. Bind result: hr = 0x80070002. The system cannot find the file specified. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under executable D:\tmp\bin\Program.exe --- A detailed error log follows. === Pre-bind state information === LOG: User = paulius_l LOG: DisplayName = Program.resources, Version=1.0.0.0, Culture=de, PublicKeyToken=... (Fully-specified) LOG: Appbase = file:///D:/tmp/bin/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = Program.exe Calling assembly : Program, Version=1.0.0.0, Culture=neutral, PublicKeyToken=.... === LOG: Start binding of native image Program.resources, Version=1.0.0.0, Culture=de, PublicKeyToken=.... WRN: No matching native image found. LOG: IL assembly loaded from D:\tmp\bin\de\Program.resources.dll.
這看起來不錯,但是字符串只是沒有得到本地化 - 從默認的Program.exe字符串仍在使用。
要獲取字符串我使用Visual Studio生成的Res
類從Res.resx
。
我在這裏錯過了什麼?
編輯:添加完整的FUSLOGVW輸出,對於那些比我更瞭解它的人。
你有沒有嘗試在Form-Constructor中設置UICulture? – Jobo
是的,我有,在調用InitializeComponent()之前。效果是一樣的。那是沒有效果的。 –
您是否驗證過(可能有反射器)衛星組件中有不同的字符串資源? – MerickOWA