【问题标题】:ASP.NET: "The resource class for this page was not found."ASP.NET:“找不到此页面的资源类。”
【发布时间】:2009-07-22 08:20:52
【问题描述】:

我自己和一位同事最近升级到了 Windows Vista,并且一直使用它来使用 Visual Studio 2008 开发 ASP.NET 应用程序,没有出现很多问题。直到今天早上,我也一直在设法很好地使用本地资源。

但是,今天早上,我的应用程序突然停止使用本地资源,因为任何具有 meta:resourcekey 属性的控件突然显示一个空字符串。起初,我认为这是我对应用程序所做的事情,所以我创建了一个全新的 Web 应用程序,为 ASPX 页面添加了一个标签,并从中生成了一个本地资源。但是运行它有同样的问题——文本根本不显示。有关示例及其输出,请参见随附的屏幕截图。

但是,在我同事的机器上运行它(他也有 Vista),没有问题。

顺便说一句,如果我试图在后面的代码中获取值,它会抛出这个异常:


Server Error in '/Resources' Application. The resource class for this page was not found.  Please check if the resource file exists and try again. 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.

Exception Details: System.InvalidOperationException: The resource class for this page was not found.  Please check if the resource file exists and try again.

Source Error:

Line 12:             protected void Page_Load(object sender, EventArgs e) Line 13:             { Line 14:        object x = HttpContext.GetLocalResourceObject("~/Default.aspx", "lblTestResource1.Text"); Line 15:     } Line 16:       }

Source File: C:\inetpub\wwwroot.Net2\Standalone\Resources\Resources\Default.aspx.cs Line: 14

Stack Trace:

[InvalidOperationException: The resource class for this page was not found.  Please check if the resource file exists and try again.]    System.Web.Compilation.LocalResXResourceProvider.CreateResourceManager()
+2468866    System.Web.Compilation.BaseResXResourceProvider.EnsureResourceManager()
+20    System.Web.Compilation.BaseResXResourceProvider.GetObject(String resourceKey, CultureInfo culture) +15  System.Web.Compilation.ResourceExpressionBuilder.GetResourceObject(IResourceProvider resourceProvider, String resourceKey, CultureInfo culture, Type objType, String propName) +21    System.Web.HttpContext.GetLocalResourceObject(String virtualPath, String resourceKey, CultureInfo culture) +38    System.Web.HttpContext.GetLocalResourceObject(String virtualPath, String resourceKey) +6    Resources._Default.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot.Net2\Standalone\Resources\Resources\Default.aspx.cs:14 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
+14    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35    System.Web.UI.Control.OnLoad(EventArgs e) +99    System.Web.UI.Control.LoadRecursive()
+50    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074

有人知道吗?奇怪的是,使用资源 起作用了。我已尝试重新启动计算机并清除我的 ASP.NET 临时文件 - 但问题仍然存在。

非常感谢

史蒂夫

【问题讨论】:

    标签: asp.net localization windows-vista


    【解决方案1】:

    好的,我在几天前进行了系统还原,现在可以正常工作了。奇怪的是,我(故意)没有对系统文件或任何东西进行任何更改。

    【讨论】:

      【解决方案2】:

      作为一种极端措施,您可以尝试修复安装 .net 框架...

      我以前从未遇到甚至听说过这个问题,所以恐怕我没有更好的解决方案。

      【讨论】:

      • 谢谢,hermiod。我考虑过这一点,但似乎没有任何方法可以在 Windows Vista 上进行全面修复。我试过运行 'sfc /scannow' 来修复系统文件,但这并没有帮助。我可能会尝试在问题发生之前进行系统还原。
      猜你喜欢
      • 2020-09-16
      • 2010-10-27
      • 2013-06-21
      • 1970-01-01
      • 1970-01-01
      • 2014-05-25
      • 1970-01-01
      相关资源
      最近更新 更多