[Mono-list] Problem when loading embedded resources

Giuseppe Greco giuseppe.greco@agamura.com
20 Jul 2003 12:35:54 +0200


On Sun, 2003-07-20 at 11:38, Gonzalo Paniagua Javier wrote:
> El s?, 19-07-2003 a las 17:13, Giuseppe Greco escribió:
> > Hi all,
> > 
> > To load a localized string, I've written a method like this:
> > 
> > public static string GetString(string name)
> > {
> >   lock(typeof(RM)) {
> >     if (resourceManager == null) {
> >       resourceManager = new ResourceManager("Gekkota.Core",
> >         (typeof(RM)).Assembly);
> >     }
> > 
> >     return resourceManager.GetString(name, null);
> >   }
> > }
> > 
> > Well, when invoking the method above, I always get the following error:
> > 
> > Unhandled Exception: System.Resources.MissingManifestResourceException:
> > Could not find any resource appropiate for the specified culture or its
> > parents (assembly:Gekkota.Core)
> > 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 Gekkota.Core.RM:GetString (string)
> > in <0x00056> 00 Gekkota.Core.Listener:set_BufferSize (int)
> > in <0x0005f> 00 Gekkota.Core.Tests.Receiver:Main ()
> >  
> > I've looked inside my assembly, and it does contain the resources
> > I'm trying to retrieve...
> > 
> > The culture of my assembly is neutral, and I provide strings localized
> > to English, German, French, and Italian.
> > 
> > Furthermore, the code above works fine with .NET on Windows.
> > Any idea?
> 
> Mmm. If it works under MS and fails with mono, it's a bug. May be you
> can file a bug report with a test case that helps us reproduce the bug
> and, hopefully, fix it.

Gonzalo, before enter a bug report, consider the following.

My assembly is defined as culture neutral, but has been localized
to four languages. The .NET documentation says that the directory
layout of *.resources files is very import... they should be organized
like this:

bin
  + en-US
  |   + myassembly.resources
  + de-DE
  |   + myassembly.resources
  + fr-FR
      + ...

The exception described above occurs because my assembly is
culture neutral, but the default resources have been
compiled into the en-US directory (if I compile the default
resource into the top directory, it does function also with
Mono on Linux).

The ResourceManager class should be able load the most
compatible resources, isn't it? 

Gius_.

> 
> -Gonzalo
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-- 
----------------------------------------
Giuseppe Greco

::agamura::

phone:  +41 (0)91 604 67 65
mobile: +41 (0)76 390 60 32
email:  giuseppe.greco@agamura.com
web:    www.agamura.com
----------------------------------------