none
C# Outlook Add-In in release mode: MissingManifestResourceException RRS feed

  • Question

  • C# Outlook 2010 Add-In.

    MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the nutral culture

    In debug mode, all ok

    In release mode, installed from setup project, fail when accessing ResourceManager for string.

    1. Set Culture

    string CultureName = "en-US";
    CultureInfo objCI = new CultureInfo(CultureName);
    Thread.CurrentThread.CurrentCulture = objCI;
    Thread.CurrentThread.CurrentUICulture = objCI;
    

    2. Get Text (names changed to protect the innocent)


    SomeControl.Text = Globals.ThisAddIn.ResMan.GetString("SomeStringResourceIdentifier");

                                                                                  ^ exception

    This is when I get the exception

    Now, I have string and image resources in a separate assembly - so when it installs, in the install directory, you'll see:

    theaddin.dll

    theaddin.resources.dll

    All are signed properly with the same (temporary test) certificate.

    How do I get the main assembly to find the resources in the other resource assembly?

    Help! Any Advice appreciated!!



    .Net thingy maker type guy.

    Saturday, August 11, 2012 10:32 PM

Answers

  • Ok, this is the interesting part.

    (I'm explaining a lot so other people will have help on this; I'm sure you don't!)

    When this was an Office 2007 Add-In, it also had string resources in a separate assembly:

    (The letter case and naming of these are CRITICAL)

    ThisAddin.dll & ThisAddin.Resources.dll

    In ThisAddin.Resources.dll, the resx files, named:

    Resources.en-US.resx

    Resources.fr-FR.resx

    Resources.es-ES.resx

    were in the project root directory, marked as 'Embedded Resource'.

    Also the 'localization object', which is simple an empty class to reference in the instantiation of the ResourceManager to find the correct assembly, was also in the root directory:

    namespace ThisAddin.Resources
    {
        [PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
        [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
        public class LocalizationObject
        {
        }
    }

    So, to instantiate the Resource Manager:

    LocRM = new ResourceManager("ThisAddin.Resources.Resources",

    typeof(ThisAddin.Resources.LocalizationObject).Assembly);


    Now we come to Outlook 2010...the above doesn't work.

    Now, with the same basic project & solution structure; I did the following (some steps may not actually be required, but this was after many trial iterations to get to work, and it works!)

    1. I had to move the string resource files into the project Properties folder.

    2. I had to rename them to resources.en-US.resx, etc... (lower case name!)

    3. Instantiation of resource manager: 

    LocRM = new ResourceManager("ThisAddin.Resources.Properties.resources",

    typeof(ThisAddin.Resources.LocalizationObject).Assembly);

    Not sure why the differences were required, really: the net result (.Net result?? lol) was the same, in terms of namespace and file naming, placement, etc.



    .Net thingy maker type guy.


    • Edited by rachmann Sunday, August 12, 2012 1:20 PM
    • Marked as answer by rachmann Sunday, August 12, 2012 1:23 PM
    Sunday, August 12, 2012 1:18 PM

All replies

  • verify that your main resource dll and sattelite dlls are copied to shadow directory from where your add-in is really loaded. You can see where it is by using process monitor when outlook starts. and maybe show us how you instantiate your resource manager
    Sunday, August 12, 2012 4:55 AM
  • Ok, this is the interesting part.

    (I'm explaining a lot so other people will have help on this; I'm sure you don't!)

    When this was an Office 2007 Add-In, it also had string resources in a separate assembly:

    (The letter case and naming of these are CRITICAL)

    ThisAddin.dll & ThisAddin.Resources.dll

    In ThisAddin.Resources.dll, the resx files, named:

    Resources.en-US.resx

    Resources.fr-FR.resx

    Resources.es-ES.resx

    were in the project root directory, marked as 'Embedded Resource'.

    Also the 'localization object', which is simple an empty class to reference in the instantiation of the ResourceManager to find the correct assembly, was also in the root directory:

    namespace ThisAddin.Resources
    {
        [PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
        [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
        public class LocalizationObject
        {
        }
    }

    So, to instantiate the Resource Manager:

    LocRM = new ResourceManager("ThisAddin.Resources.Resources",

    typeof(ThisAddin.Resources.LocalizationObject).Assembly);


    Now we come to Outlook 2010...the above doesn't work.

    Now, with the same basic project & solution structure; I did the following (some steps may not actually be required, but this was after many trial iterations to get to work, and it works!)

    1. I had to move the string resource files into the project Properties folder.

    2. I had to rename them to resources.en-US.resx, etc... (lower case name!)

    3. Instantiation of resource manager: 

    LocRM = new ResourceManager("ThisAddin.Resources.Properties.resources",

    typeof(ThisAddin.Resources.LocalizationObject).Assembly);

    Not sure why the differences were required, really: the net result (.Net result?? lol) was the same, in terms of namespace and file naming, placement, etc.



    .Net thingy maker type guy.


    • Edited by rachmann Sunday, August 12, 2012 1:20 PM
    • Marked as answer by rachmann Sunday, August 12, 2012 1:23 PM
    Sunday, August 12, 2012 1:18 PM