Localization issue on Xbox (UWP)

I have an error that occurs to a small percentage of users of my app, only on German Xbox. English users and PC users are fine.

My code looks like this:

Uri fileName = new Uri("ms-appx:///Assets/Content/MyData.json");
StorageFile myFile = await StorageFile.GetFileFromApplicationUriAsync(fileName);
IBuffer buf = await FileIO.ReadBufferAsync(myFile);

This is called from App.xaml.cs OnLaunched event on app start-up:

protected override async void OnLaunched(LaunchActivatedEventArgs e)

For the unlucky few the ReadBufferAsync statement results in element not found error:

System.Exception: Element nicht gefunden. (Exception from HRESULT: 0x80070490)

One user was good enough to reinstall the app, and the same error happens, so it seem to be persistent, it is not a timing issue on start-up or installation issue.

Json file is stored in these folders in my project for the two languages I support:

\Assets\Content\language-de\MyData.json
\Assets\Content\language-en\MyData.json

My suspicion is that the problem has to do with UWP localization as it does not seem to be happening to English language users which are a large majority of my users. I cannot replicate this myself. If I change the locale on my PC to de-DE or de-CH it works fine and it displays content in German.

I am only aware of the issue thanks to AppCenter reporting and one user taking the time to email me about it.

Any ideas what I could do to fix or work around this issue or at least how to get more info on what the issue is. I am not sure what the element not found error means in this context.


Solution 1:

Tried a few different things, but it was not working. Seems there is an issue with developer content localization on Xbox. String localization works OK.

As a workaround I ended up implementing my own logic to select the correct file instead of relying on Microsoft resource manager:

Uri fileName = new Uri("ms-appx:///Assets/Content/MyData.english.json");

string topUserLanguage = GlobalizationPreferences.Languages[0];

//override default file if german language is detected                
if(topUserLanguage.StartsWith("de"))
{
    fileName = new Uri("ms-appx:///Assets/Content/MyData.german.json");
}