Click here to Skip to main content
Click here to Skip to main content

Error Resolved: IOException - Cannot locate resource

, 4 Sep 2013
Rate this:
Please Sign up or sign in to vote.
Issue with WPF app while performing localization

Introduction 

Recently I worked on a WPF application which supports localization using LocBAML tool. I created a sample application, having a very simple UI, consist of a button inside a window. Here I am assuming that most of you are aware on how to generate satellite assemblies. So, quickly coming to the point, when I build my application, build was successful. But when I launched, my application crashed with reason stated as IOException. Alas !!! 

 

 

After spending almost an hour, I came to know that it was due to Culture settings. Let's have a look at my code first:

Using the code 

My App.xaml.cs looks like this:  

public partial class App : Application
    {
        public App()
        {
            CultureInfo fr = new CultureInfo("fr-FR");
            Thread.CurrentThread.CurrentCulture = fr;
            Thread.CurrentThread.CurrentUICulture = fr;           
        }
    }  

Apart from this above code, I also updated my project file (.csproj) for development language so that my satellite assembly contains the neutral language resources. Following line was added in the project file:  

<UICulture>en-US</UICulture> 

Apart from this, I did nothing special in my app. After hitting my head on msdn, I got an idea on why culture changes was causing an exception.

Well, no need to get panic. Solution is pretty simple. Let's move ahead and open your assembly.info.cs file and uncomment below line: 

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

After this minor change, we are good to go.
By uncommenting this line, we are telling runtime that culture information needs to be read from satellite assembly.

Hope, this tip will save your time Smile | :)  

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Shweta Lodha
Technical Lead
India India
You can also follow me at my blog http://www.shwetalodha.blogspot.in/
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 4 Sep 2013
Article Copyright 2013 by Shweta Lodha
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid