【发布时间】: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