我第一次使用Resx文件。因此,按照以下步骤操作,直到现在为止。
添加一个网页,并在后面的代码中编写以下代码:
protected void Page_Load(object sender, EventArgs e)
{
ResourceManager rm = new ResourceManager("UsingRESX.Resource1",
Assembly.GetExecutingAssembly());
String strWebsite = rm.GetString("Website", CultureInfo.CurrentCulture); // here I get the exception
String strName = rm.GetString("Name");
form1.InnerText = "Website: " + strWebsite + "--Name: " + strName;
}
但是当我运行代码时,我得到了异常:
Could not find any resources appropriate for the specified
culture or the neutral culture. Make sure "UsingRESX.Resource1.resources"
was correctly embedded or linked into assembly "WebApplication1" at compile
time, or that all the satellite assemblies required are loadable and fully signed.
本练习遵循的教程: Read Resx FIle
我尝试过的SO解决方案: SO Solution
答案 0 :(得分:1)
尝试添加
var assembly = Assembly.GetExecutingAssembly();
assembly.GetManifestResourceNames();
并设置一个断点。这将列出所有嵌入式资源。确保您使用正确的名称。有时资源路径并不完全清楚。