Forum Xamarin Xamarin.Forms

Multiple resources files in multiple modules in Xamarin Project.

albertoha94albertoha94 Member ✭✭✭

I am currently working in a Xamarin.Forms project where I have the following modules:

To summarize this modules:

  • .Android is your standard Android module.
  • .Cache-BFTG is a module where we handle all the database interactions (Insert, Update, Delete, Search Queries).
  • Fighter-Movelist is the root Xamarin.Forms project where I store my pages and MVVM.

In Fighter-Movelist I have a resources file that I use to store my translations of labels. However, I was going to add some "Default values" to some items in my database and I thought the best thing would be that rather than adding the strings to the database, it would be best to add the id of the resource and then access it. Like that the app would change the value depending on the current locale of the device.

So I did that, I added the following values:


And created a resources file in the cache module:

Once i created the file, i modified the code i used to retrieve the values of the resources files to also check for the other directory:

 public class TranslateExtension : IMarkupExtension
        const string ResourceId = "Fighter_MoveList.Resources.AppResources";
        const string ResourceIdCache = "Fighter_MoveList.Cache_BFTG.Resources.AppResources";

        static readonly Lazy<ResourceManager> resmgr = new Lazy<ResourceManager>(
            () => new ResourceManager(ResourceId, typeof(TranslateExtension).GetTypeInfo().Assembly)

        static readonly Lazy<ResourceManager> resmgrCache = new Lazy<ResourceManager>(
            () => new ResourceManager(ResourceIdCache, typeof(TranslateExtension).GetTypeInfo().Assembly)
public static string GetString(string key)
            var cultureInfo = CrossMultilingual.Current.CurrentCultureInfo;
            var translation = resmgr.Value.GetString(key, cultureInfo);

            if (translation == null)

                // Try again but with Cache.
                    translation = resmgrCache.Value.GetString(key, cultureInfo);
                catch(Exception e)

                if (translation == null)
                    throw new ArgumentException(
                    String.Format("Key '{0}' was not found in resources '{1}' for culture '{2}'.", key, ResourceId, cultureInfo.Name),
                return key;

            return translation; // returns the key, which GETS DISPLAYED TO THE USER

However, this throw the following error:

Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "Fighter_MoveList.Cache_BFTG.Resources.AppResources.resources" was correctly embedded or linked into assembly "Fighter-Movelist" at compile time, or that all the satellite assemblies required are loadable and fully signed.

However, the designer path does match and I have the resource embedded. What else am I missing?


Sign In or Register to comment.