创建资源经理,我想我的网页上创建资源管理器,并使用存储在我的资源文件中的一些数据。 (为Default.aspx.resx和default.aspx.en.resx)如何在ASP.NET
的代码看起来是这样的:
System.Resources.ResourceManager myResourceManager = System.Resources.ResourceManager.CreateFileBasedResourceManager("resource",
Server.MapPath("App_LocalResources") + Path.DirectorySeparatorChar, null);
if (User.Identity.IsAuthenticated)
{
Welcome.Text = myResourceManager.GetString("LoggedInWelcomeText");
}
else
{
Welcome.Text = myResourceManager.GetString("LoggedOutWelcomeText");
}
,但是当我编译和我的本地服务器上运行它,我得到这个类型的错误:
Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName: resource locationInfo: fileName: resource.resources Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
异常详细信息:System.Resources.MissingManifestResourceException:找不到任何资源适合指定区域性(或中性文化)在磁盘上。 baseName的:资源locationInfo:文件名:resource.resources
源错误:
89行:别的90 行:{ 线91:Welcome.Text = myResourceManager.GetString( “LoggedOutWelcomeText”); 92行:} 93行:
请问您可以帮我解决这个问题吗?
是的,我有default.aspx.en.resx和App_LocalResources文件为Default.aspx.resx同时还有名称为“LoggedOutWelcomeText” – Bart 2010-04-04 14:28:37
OK行,但名称不要”从“资源”开始,这就是你对CreateFileBasedResourceManager的调用所告诉的内容。 – Timores 2010-04-05 09:35:01