0

我知道关于 SO 有很多类似的问题,但我的问题并不完全相同,建议的解决方案对我不起作用。

因此,我创建了名为“MyApp 1.0”的 C#.NET 桌面应用程序,但后来将默认命名空间更改为MyApp. 现在,我希望我的应用程序以各种语言进行本地化,因此我添加了新的资源文件来保留每种语言的 UI 字符串,如MyAppUIText.en.resxMyAppUIText.gu.resx等等。我还创建了一个类,该类具有public static从应用程序中的任何位置访问这些资源的字符串的方法,其代码如下。

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);
            }
        }
    }
}

当我运行我的应用程序时,出现以下运行时错误

找不到适合指定区域性或中性区域性的任何资源。确保“MyApp.MyAppUIText.resources”在编译时被正确嵌入或链接到程序集“MyApp 1.0”中,或者所有所需的附属程序集都是可加载的并且完全签名。

但是,字符串已正确加载到 UI 中,但是,表单设计器显示与 title 相同的错误To prevent possible data loss before loading the designer, the following errors must be resolved:

我在这里做错了什么?

PS 我是 C# 的新手,但我精通 Java,并且以前使用过它的properties文件。

4

1 回答 1

1

您已删除或重命名 MyApp.MyAppUIText.resx 文件。确保表单的语言设置为(默认),更改表单上的一些文本,更改表单的 Text 属性即可。VS 将创建一个新的 MyApp.MyAppUIText.resx 文件,构建您的解决方案并运行它。

于 2013-01-24T19:12:58.257 回答