I am creating a Xamarin.Forms app based on a C# shared code project and another two projects for the actual Android + iOS app.
I now want to implement string localization like it is documented here. So I created a .net standard 2.0 library project in my solution for the .resx file and referenced this project in my two main projects, and I did all the other steps described in the linked article, of course.
When I now want to access any of my string resources from one of my app projects, ResourceManager.GetString
throws this Exception: System.IO.FileNotFoundException: Invalid Image
Example code would be that line, but it can be also any other string resource.
public static string global_copyright {
get {
return ResourceManager.GetString("global_copyright", resourceCulture);
}
}
I can confirm that the assembly of this library project is found and loaded correctly, since I can create instances of other classes defined in that project.
Now I put this code directly at the beginning of the App() constructor like it is described in that article to debug for such issues:
var assembly = typeof(AppResources).GetTypeInfo().Assembly;
foreach (var res in assembly.GetManifestResourceNames())
{
System.Diagnostics.Debug.WriteLine("found resource: " + res);
}
var test = AppResources.global_copyright;
The first lines are executed fine and it shows me that one resource file is found in that assembly. Its name is also correct. But on the last line it crashes with that exception. What did I wrong? Why is ResourceManager not able to load string resources from that assembly?
Visual Studio 2017 (15.9.6) with Xamarin.Forms v3.4