Reputation: 3168
I know there are plenty of similar questions on SO but my problem is not exact same and suggested solutions doesn't work for me.
So, I've created C#.NET desktop app with name "MyApp 1.0", but later changed default Namespace to MyApp
. Now, I want my app to localized in various languages so I added new resource file to keep UI strings for each language, as MyAppUIText.en.resx
, MyAppUIText.gu.resx
and so on. I have also created a class with public static
methods to access strings from these resources anywhere in the application, code of which is as follows.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Resources;
namespace MyApp
{
namespace Utility
{
class UIText
{
private static ResourceManager rm = new ResourceManager("MyApp.MyAppUIText", typeof(FormMyAppMain).Assembly);
public static string GetString(string key)
{
return rm.GetString(key, System.Globalization.CultureInfo.CurrentUICulture);
}
}
}
}
When I run my app, I get following runtime error
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyApp.MyAppUIText.resources" was correctly embedded or linked into assembly "MyApp 1.0" at compile time, or that all the satellite assemblies required are loadable and fully signed.
But, strings are loaded in the UI correctly, however, Form designer shows the same error with title To prevent possible data loss before loading the designer, the following errors must be resolved:
.
What am I doing wrong here?
P.S.
I'm new to C# but I'm well versed with Java and have worked with its properties
file before.
Upvotes: 0
Views: 1625
Reputation: 118
You have deleted or renamed the MyApp.MyAppUIText.resx file. Make sure that the Language of your form is set to (Default), change some text on the form, changing the Text property of the Form will do it. VS will create a new MyApp.MyAppUIText.resx file, Build your solution and run it.
Upvotes: 1