We are currently moving our Xamarin projects from PCL to .Net Standard 2.0, also core library project format. Most things works well. We use resx-files in the core project for localization. This works fine on iOS and Android.
On UWP I get null
as value, if I try to access the string ressources
var buttonText = AppResources.Cancel; // => null
The PCL version the same code worked well. Is there some initialization needed?
On debug I can see that the resource manager has a null
ResourceSet, but _WinRTResourceManager
is filled.
Finally I found the reason.
By converting PCL library to .Net Standar normally the file AssemblyInfo.cs
is not there. So the neutral language definition get lost.
We use German (de-DE) as default language. As soon as I change the default langugage in Package.appxmanifest
from the default value en-US
to de-DE
the resources from .Net Standard library could not be read.
The fix is, to define explixit the NeutralResourcesLanguage for the .Net Standard library (to the same as UWP project). This can be done in manually created AssemblyInfo.cs (do not forget to turn off auto generation of AssemblyInfo) or declare this info in one of the exsisting classes with [assembly: NeutralResourcesLanguage("de-DE")]
.
After this fix the resources from .Net Standard library are used correctly also in UWP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With