Click here to Skip to main content
15,911,896 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Ref: https://www.codeproject.com/Articles/299436/WPF-Localization-for-Dummies"

The above example works fine for a project:resource ratio of 1:1, but ....

When you scale up, and have several application projects in a solution that are all language dependant it's much easier to maintain one language resource file.

To achieve this I have:
1. Created a Class Library Project called 'GlobalLanguage' and added a language resource to it that will be the common language resource to all my appl. projects in the solution
2. The default namespace for this GlobalLanguage project is: Company.Product.GlobalLanguage
3. I then add this project class library as a reference to my appl project.
4. My appl project has an existing local resource (which I intend to remove once I get the global laguage resource working) The namespace of the appl project is Company.Product.Appl
5. my appl xaml page has two namespace references:
xmlns:localLang="clr-namespace:Company.Product.Appl.Properties"
xmlns:GlobalLang="clr-namespace:Company.Product.GlobalLanguage.Properties"
VS2015 shows an error in the underlined section above, Why?
6. When I refer to the GlobalLanguage language resource in a *.cs source within the appl project it works fine. Eg:
string msg = Company.Product.GlobalLanguage.Properties.Resources.ErrorUserNotAllowed;

The error in the XAML page is
"Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'Company.Product.GlobalLanguage' that could not be found." (See ref #3 : problem doesnt go away after compile)

What I have tried:

Have reviewed:
#1
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d4348323-7326-4fc1-afd4-239e8fdb5fc0/wpf-undefined-clr-namespace-the-clrnamespace-uri-refers-to-a-namespace-that-is-not-included?forum=wpf

#2
https://www.codeproject.com/Articles/299436/WPF-Localization-for-Dummies"


#3
https://stackoverflow.com/questions/3425954/the-clr-namespace-uri-refers-to-a-namespace-that-is-not-included-in-the-assemb
Posted
Updated 19-Dec-17 12:49pm

1 solution

OK, Solved it with help of resharper:

Xaml namespace reference should be:

xmlns:globalLang="clr-namespace:Company.Product.GlobalLanguage.Properties;assembly=Company.Product.GlobalLanguage"



WPF XAML Usage:
<TextBlock FontWeight="Bold" FontSize="24" TextAlignment="Center" VerticalAlignment="Center" Foreground="#FF4D4D4D" Text="{x:Static globalLang:Resources.Error}"/>

WPF C# Usage:
var msg = Company.Product.GlobalLanguage.Properties.Resources.Error;
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900