[Mono-bugs] [Bug 46638][Cri] New - ResourceManager unable to load default resources

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Sun, 20 Jul 2003 08:27:56 -0400 (EDT)


In-Reply-To: <bug-46638@chernobyl.ximian.com>
X-Bugzilla-Product: Mono/Class Libraries
X-Bugzilla-Component: System
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: Critical
X-Bugzilla-Severity: 
X-Bugzilla-Target-Milestone: ---

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by giuseppe.greco@agamura.com.

http://bugzilla.ximian.com/show_bug.cgi?id=46638

--- shadow/46638	Sun Jul 20 08:27:56 2003
+++ shadow/46638.tmp.19478	Sun Jul 20 08:27:56 2003
@@ -0,0 +1,147 @@
+Bug#: 46638
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Critical
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: giuseppe.greco@agamura.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: ResourceManager unable to load default resources
+
+
+The .NET documentation says that the directory layout of *.resources
+files should be organized like this:
+
+bin
+  + en-US
+  |   + myassembly.resources
+  + de-DE
+  |   + myassembly.resources
+  + fr-FR
+  |   + ...
+  + ...
+
+If you create a culture neutral assembly and select en-US as the
+default language, the ResourceManager class is not able to load
+the resources at all.
+
+Steps to reproduce the problem:
+
+
+1. Create a .resx file like the following and save it into the
+   en-US subdirectory:
+
+<?xml version="1.0" encoding="utf-8"?>
+                                                                          
+                      <root>
+  <data name="Message_Hello">
+    <value>
+      Hello!
+    </value>
+  </data>
+  <resheader name="ResMimeType">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="Version">
+    <value>0.0.1.1</value>
+  </resheader>
+  <resheader name="Reader">
+    <value>System.Resources.ResXResourceReader</value>
+  </resheader>
+  <resheader name="Writer">
+    <value>System.Resources.ResXResourceWriter</value>
+  </resheader>
+</root>
+
+
+2. Create the following *.cs files:
+
+   2.1 RM.cs:
+
+
+using System.Resources;
+using System.Reflection;
+                                                                          
+                      
+internal sealed class RM
+{
+  private static ResourceManager resourceManager;
+                                                                          
+                      
+  public static string GetString(string name)
+  {
+    lock(typeof(RM)) {
+      if (resourceManager == null) {
+        resourceManager = new ResourceManager("hello",
+          (typeof(RM)).Assembly);
+      }
+                                                                          
+                      
+      return resourceManager.GetString(name, null);
+    }
+  }
+}
+
+
+  2.2 hello.cs:
+
+
+using System;
+                                                                          
+                      
+public class Hello
+{
+  public static void Main()
+  {
+    Console.WriteLine("{0}", RM.GetString("Message_Hello"));
+  }
+}
+
+
+4. Compile the whole:
+
+   in the en-US subdirectory:
+
+     monoresgen hello.resx
+
+   in the project's top directory:
+
+     mcs -t:exe -out:hello.exe -res:en-US/hello.resources *.cs
+
+Actual Results:
+
+The following exception is thrown:
+
+Unhandled Exception: System.Resources.MissingManifestResourceException:
+Could not find any resource appropiate for the specified culture or its
+parents (assembly:hello)
+in <0x00330> 00 System.Resources.ResourceManager:InternalGetResourceSet
+(System.Globalization.CultureInfo,bool,bool)
+in <0x00097> 00 System.Resources.ResourceManager:GetString
+(string,System.Globalization.CultureInfo)
+in <0x0009f> 00 .RM:GetString (string)
+in <0x0000f> 00 .Hello:Main ()
+
+
+Expected Results:
+
+The linked en-US resources should be read by the ResourceManager class
+and the application should be able to display the message "Hello!".
+
+
+How often does this happen? 
+
+Always.
+
+
+Additional Information:
+
+The code above works fine with .NET on Windows.