In a Xamarin Forms iOS/Android app I've been using a single .resx file for some time. Now, I'm getting 'MissingManifestResourceException', 'Could not find any resources appropriate for the specified culture or the neutral culture'. This seemed to coincide with installing XS 5.91 but can't be sure on that.
Reverting to XS 5.9 and retrieving a backup copy of my app from before the problem started, I found curiously that the app would run but as soon as I made any edit however trivial to my .resx file, the error would return. Experimenting further, I built a minimal app having a .resx file, and it had the same problem. Next, I downloaded the .resx sample app at http://developer.xamarin.com/guides/cross-platform/xamarin-forms/localization/ . It too ran correctly first up. Interestingly, it includes reflection code to check that the resource file is indeed embedded, and output a message showing that it was. However, as soon as I made a trivial edit to its default .resx file, it got the same error when next run.
Getting somewhat desperate now, I (completely) uninstalled Xamarin iOS, Xamarin Android and XS, following the guide at http://developer.xamarin.com/guides/cross-platform/getting_started/installation/uninstalling_xamarin/ . Then I went back a couple of versions and installed iOS8.9.1, Android 4.20.2 and XS 5.8.3. I re-downloaded the sample .resx app just to be sure, and tried it out. Same result -- it runs first time but gets the error after any trivial edit is made to the default .resx file.
I believe I've checked all the usual things like build action of the .resx being Embedded Resource. Xcode is V6.3. My tests were with the iOS side.
Running out of ideas here, and of course can't progress with my app. Would be so grateful for any suggestions.
Posts
To be clear, the .resx is in the PCL and the startup project is iOS.
My Bugzilla bug report posted here: https://bugzilla.xamarin.com/show_bug.cgi?id=30170
(Very) temporary workaround:
I think you are seeing bug 30044 in Xamarin Studio 5.9. In Xamarin Studio 5.8 you should be able to fix the problem by configuring the .NET naming policy, more on this below.
The problem in Xamarin Studio 5.9 is that it is generating a different resource name in the AppResources.Designer.cs file. The unmodified code on GitHub is:
The
"UsingResxLocalization.Resx.AppResources"
string being passed to the resource manager is the important part.I suspect when you edit the .resx file and save it the string is being changed to
"UsingResxLocalization.AppResources"
which is the problem reported in bug 30044.In Xamarin Studio 5.9 you should be able to workaround this by changing the Resource Id in the properties for each .resx file so it is the correct string. Another slightly hacky way is to change the default namespace of the project to be
"UsingResxLocalization.Resx"
. Another workaround would be to move the resource files into the root directory of the project.In Xamarin Studio 5.8 I believe you will need to configure the .NET Naming policy in the project options so the correct resource name string is generated. If you check both Associate namespaces with directory names and Use default namespace as root then re-save the .resx file it should generate the correct string in the designer file. By default it generates the resource name without the directory name.
Thanks @mattward. Excising ".resx" from the .resx file's ResourceId property fixed my problem.
I have the same problem...
I had the same desperate problem @BillFulton, then i hit this page at 4 AM
I am getting the error just launching an unmodified copy of UseResxLocalization demo on android on the latest version of Xamarin & Xamarin Studio.
Any suggestions?
My issue was, that I had previously been changing the namespace for my entire solution by first changing the Default Namespace in the project properties and thereafter using ReSharper to adjust the namespaces automatically.
I personally solved the issue I had by opening
./Resources/AppResources.rex/AppResources.Designer.cs
where I found that the namespace hadn't been changed for theResourceManager
automatically.I simply changed the ´OLD.NAMESPACE` (see code below) to my new namespace which fixed the issue:
Hmm. This problem re-emerged, seemingly coincident with installing Xamarin 4.
In my case I solved it by restoring the ".resx" that I had previously excised to get things working in an earlier version - see my comment above dated May 21, 2015. Sounds like the bug has been fully addressed now ...
I'm getting a similar error and I've tried all of the above steps
{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MobileGateApp.AppResources.resources" was correctly embedded or linked into assembly "PatrolLiveApp" at compile time, or that all the satellite assemblies required are loadable and fully signed.
I did rename namespaces all over my solution using resharper , from MobileGateApp to PatrolLiveApp
The above error would indicate it is still looking for a resource file named MobileGateApp:
Make sure "MobileGateApp.AppResources.resources" was correctly embedded
Where is this MobileGateApp.AppResources.resources ?
Same here, tried all above fixes, still the problem persists.
Same here by error. Changed Resource to public and forgeted to change the custom tool to PublicResXFileCodeGenerator
Had same problem, was hard to fix, after getting the code from the xamarin forms resx localization article and sample code.. The point was the mismatch between namespaces. I hope that was your case, so we could fix it. When you make all namespaces dependencies match in different places everything will suddenly work
When you create a ResX resource table you gave it a name like YourResXTablename (mine was name just "Res").
ResX custom tools auto-generate namespace for your brand new resource tables as Yourappnamespace.ResX. It will reside inside YourResXTablename.Designer.cs and must not be changed as the compiler will overwrite it.
In the Shared project:
ILocalize
interface has to have same namespace as the auto-generated for resources (Yourappnamespace.ResX).class TranslateExtension
same, set namespace to Yourappnamespace.ResX.const string ResourceId = "Yourappnamespace.ResX.YourResXTablename";
In Android project:
public class Localize : ILocalize
Set namespace same as your main android project namespace (Yourappnamespace.Droid or Yourappnamespace.Android)[assembly: Xamarin.Forms.Dependency(typeof(Yourappnamespace.Droid.Localize))]
to match your Android project namespace.In iOS etc - proceed like for Android.
The usage in XAML can be cleaner than proposed in xamarin article:
Every page include
xmlns:resX="clr-namespace:Yourappnamespace.ResX;assembly=Yourappnamespace"
and the string goes asText="{resX:Translate StringName}"
.Or.. dunno how but
Text="{x:Static resX:Res.StringName}"
translates fine too..@NickKovalsky thanks a lot, your post helped me out of my problems!
In my Xamarin version the autogenerated namespace of YourResXTablename.Designer.cs was no longer Yourappnamespace.ResX. My version generated only Yourappnamespace.
So had to leave out the ".ResX".
At the end my problem was that I also got the code from the xamarin forms resx localization article - and I had to change the line you mentioned above to:
const string ResourceId = "Yourappnamespace.YourResXTablename";**
Try also looking in your Pro file. I've had same problem and in my Proj file remain old name