Localising a WPF application doesn't work?

Viewed 1690

I must be missing something here.

I create a brand new WPF application in VS2015. I create a resource 'String1' and set the value to 'fksdlfdskfs'.

I update the default MainWindow.xaml.cs so that the constructor has:

    public MainWindow()
    {
        InitializeComponent();
        this.Title = Properties.Resources.String1;
    }

And run the application, and it works fine, my window title is fksdlfdskfs.

In the AssemblyInfo.cs file I see the below comments:

//In order to begin building localizable applications, set 
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>.  For example, if you are using US english
//in your source files, set the <UICulture> to en-US.  Then uncomment
//the NeutralResourceLanguage attribute below.  Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]

So I add the following into my WpfApplication5.csproj file and reload the project in VS:

<UICulture>en-US</UICulture>

And then uncommented the following line in AssemblyInfo.cs:

[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]

If I now go to run the application, the application no longer runs and I get the following exception on the line where I read the resource:

System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "WpfApplication5.Properties.Resources.en-US.resources" was correctly embedded or linked into assembly "WpfApplication5" at compile time, or that all the satellite assemblies required are loadable and fully signed.

If I change UltimateResourceFallbackLocation.Satellite to UltimateResourceFallbackLocation.MainAssembly in the AssemblyInfo.cs file, I get the following exception instead:

System.IO.IOException: Cannot locate resource 'mainwindow.xaml'

What am I doing wrong or what am I missing?

1 Answers
Related