G
Gary
am having some trouble accessing culture specific resources using Vs.Net
2005, what process have I missed?
* Created a Windows Forms Application called GlobalTest
* Created the following code in button1_Click :
ResourceManager rm = new ResourceManager("strings",
this.GetType().Assembly);
CultureInfo ci = new CultureInfo("en-US");
MessageBox.Show(rm.GetString("test", ci));
* Added a file called 'strings.en-US.resx' to my project and created a
string entry with the name 'test' and a value of 'hello world'.
Created a key.snk using sn -k key.snk at the VS2005 command prompt and
signed my Windows Application with it.
VS.NET 2005 builds the application and satellite assembly with the following
parameters -
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig
/nowarn:1701,1702 /errorreportrompt /warn:4 /defineEBUG;TRACE
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
/debug+ /debug:full /keyfile:key.snk /optimize-
/outbj\Debug\GlobalTest.exe /resourcebj\Debug\GlobalTest.Form1.resources
/resourcebj\Debug\GlobalTest.Properties.Resources.resources /target:winexe
Form1.cs Form1.Designer.cs Program.cs Properties\AssemblyInfo.cs
Properties\Resources.Designer.cs Properties\Settings.Designer.cs
Compile complete -- 0 errors, 0 warnings
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\AL.exe /culture:en-US
/keyfile:key.snk /outbj\Debug\en-US\GlobalTest.resources.dll
/templatebj\Debug\GlobalTest.exe
/embedbj\Debug\GlobalTest.strings.en-US.resources
GlobalTest -> C:\Documents and Settings\gary\My Documents\Visual Studio
2005\Projects\GlobalTest\GlobalTest\bin\Debug\GlobalTest.exe
I get the following error message -
System.Resources.MissingManifestResourceException: Could not find any
resources appropriate for the specified culture or the neutral culture.
Make sure "strings.resources" was correctly embedded or linked into assembly
"GlobalTest" at compile time, or that all the satellite assemblies required
are loadable and fully signed.
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo
culture)
at GlobalTest.Form1.button1_Click(Object sender, EventArgs e) in
C:\Documents and Settings\gary\My Documents\Visual Studio
2005\Projects\GlobalTest\GlobalTest\Form1.cs:line 27
2005, what process have I missed?
* Created a Windows Forms Application called GlobalTest
* Created the following code in button1_Click :
ResourceManager rm = new ResourceManager("strings",
this.GetType().Assembly);
CultureInfo ci = new CultureInfo("en-US");
MessageBox.Show(rm.GetString("test", ci));
* Added a file called 'strings.en-US.resx' to my project and created a
string entry with the name 'test' and a value of 'hello world'.
Created a key.snk using sn -k key.snk at the VS2005 command prompt and
signed my Windows Application with it.
VS.NET 2005 builds the application and satellite assembly with the following
parameters -
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig
/nowarn:1701,1702 /errorreportrompt /warn:4 /defineEBUG;TRACE
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
/debug+ /debug:full /keyfile:key.snk /optimize-
/outbj\Debug\GlobalTest.exe /resourcebj\Debug\GlobalTest.Form1.resources
/resourcebj\Debug\GlobalTest.Properties.Resources.resources /target:winexe
Form1.cs Form1.Designer.cs Program.cs Properties\AssemblyInfo.cs
Properties\Resources.Designer.cs Properties\Settings.Designer.cs
Compile complete -- 0 errors, 0 warnings
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\AL.exe /culture:en-US
/keyfile:key.snk /outbj\Debug\en-US\GlobalTest.resources.dll
/templatebj\Debug\GlobalTest.exe
/embedbj\Debug\GlobalTest.strings.en-US.resources
GlobalTest -> C:\Documents and Settings\gary\My Documents\Visual Studio
2005\Projects\GlobalTest\GlobalTest\bin\Debug\GlobalTest.exe
I get the following error message -
System.Resources.MissingManifestResourceException: Could not find any
resources appropriate for the specified culture or the neutral culture.
Make sure "strings.resources" was correctly embedded or linked into assembly
"GlobalTest" at compile time, or that all the satellite assemblies required
are loadable and fully signed.
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo
culture)
at GlobalTest.Form1.button1_Click(Object sender, EventArgs e) in
C:\Documents and Settings\gary\My Documents\Visual Studio
2005\Projects\GlobalTest\GlobalTest\Form1.cs:line 27