Resource Manager not working in Compact Framework v2.0 and Pocket PC 2003 SE Emulator

Hello all,

The ResourceManager class will not find a resource under the Compact Framework v2.0.  However, this used to work under CFv1.0. 

Let me elaborate on my problem.  I have my main program in main.dll and a resource with name 'Messages.en.resources' in main.resources.dll. 

Here is the code in the main.dll:

ResourceSet _msgs;

ResourceManager rm = new ResourceManager( "Messages", Assembly.GetExecutingAssembly() );

try {
   _msgs = rm.GetResourceSet( CultureInfo.CurrentUICulture, true, true );
} catch( MissingManifestResourceException ) {
   _msgs = null;
}

if ( _msgs == null ) {
   try {
      _msgs = rm.GetResourceSet( CultureInfo.CurrentCulture, true, true );
   } catch( MissingManifestResourceException ) {
      try {
         _msgs = rm.GetResourceSet( new CultureInfo( "en" ), true, true );
      } catch (MissingManifestResourceException ) {
      }
   }
}

When the above code is run, every single Exception occurs. 

I am using the Pocket PC 2003 Second Edition Emulator from the Microsoft Device Emulator Preview, and I am compiling my code for the ARM processor.

Does anybody know what is causing my problem

Thanks,

- Jeffrey


Answer this question

Resource Manager not working in Compact Framework v2.0 and Pocket PC 2003 SE Emulator

  • Richard Blackburn

    Hi Jeffrey,

    Yes. The calls to ResourceManager.GetResourceSet() was successful, no matter whether the resource used has an invariant culture, a neutral culture, or a specific culture (My application has all 3 kinds of resources with the same base name). The calls returns instances of ResourceSet that I was able to use to retrieve the stored resource strings.

    Cheers,
    Anthony Wong [MSFT]

  • jjoravec

    The resource file contains only strings.

    - Jeffrey Liu


  • C#Architect

    Hi Jeffrey,

    I was not able to reproduce the issue you mentioned. Did you use Visual Studio 2005 to create the device project Was the resource file used by the application generated by VS 2003 or VS 2005 when you run the application against NETCF V2 Could you send me a small project containing codes that reproduce the issue Also, you may need to include the project's namespace name in the base name you pass to create the ResourceManager instance.

    Cheers,
    Anthony Wong [MSFT]

  • zespri

    I should also mention that my main.resources.dll is a satellite assembly, and that main.dll does not have a default resource assembly.
  • John Mark Howell

    I've been preparing a small demo for you, but it works in the emulator.  I must be doing something incorrect in my actual app.  I'll have to look into this further.

    Thanks for your help so far,
    Jeffrey Liu


  • PeterSpanien

    Hi Jeffrey,

    Say if the project name is DeviceApplication1, and you name the resource files as Resource1.resx, Resource1.en.resx, Resource1.fr-FR.resx, etc, then the base name string should be DeviceApplication1.Resource1. Note that the .resx files should be placed in the project directory, not a subdirectory below it.

    Yes, it would be helpful to send a small project to me for further investigation. Please send it to Anthony.Wong@microsoft.com.

    Cheers,
    Anthony Wong [MSFT]

  • Thomas B

    I've figured out the cause of the problem.

    I mentioned before that my program was contained in main.dll and my resources were contained in en\main.resources.dll.

    The problem was that I was signing main.dll with a .snk keyfile but not signing the resources dll.  This worked in Visual Studio 2003, but it will not work in Visual Studio 2005.

    Note that this issue occurs with the .NET Compact Framework v2.0 and not with .NET framework v2.0.

    The solution is to sign both dll's.

  • P.V.Shanthi

    Hi Jeffrey,

    Also, could you let me know if what data is contained in the resource Does the issue repros with a resource file containing only strings

    Cheers,
    Anthony Wong [MSFT]

  • jarda.jirava

    Thanks for the quick reply.

    I use VS2005 csc.exe to compile my project.  The resource file is generated by VS2005.  How would the base-name string look with the project's namespace included

    I don't have a VS2005 project, because we develop outside of VS2005.  If none of your solutions work, then I'll make a small project for you. 

    - Jeffrey Liu

  • Anusuya

    When you were trying to reproduce my issue, was your call to ResourceManager.GetResourceSet() successful

    Thanks,
    - Jeffrey Liu


  • Resource Manager not working in Compact Framework v2.0 and Pocket PC 2003 SE Emulator