我已阅读http://msdn.microsoft.com/en-us/library/ms149953.aspx,需要验证我的GetLocalResourceObject
虚拟路径是什么。
我的本地资源文件位于我的电脑上:
C:\的Inetpub \ wwwroot的\ GlobalX \输入\ App_LocalResources文件
在此文件夹中是我的网站处理的所有语言的资源文件(InputContactDetails.aspx.ro.resx,InputContactDetails.aspx.hi.resx等),以及默认资源文件(InputContactDetails.aspx。 RESX)。
尝试实现虚拟路径字符串时收到错误。以下是我的违规代码:
return '<%= HttpContext.GetLocalResourceObject("~/GlobalX/Input/App_LocalResources/InputContactDetails.aspx.resx", "ContactDetails.Text", new System.Globalization.CultureInfo("ro")) %>';
我已经尝试~/GlobalX/Input/App_LocalResources
作为虚拟路径和其他几种排列,但我得到了同样的错误。
如果有人能够证明我做错了什么,我会非常感激。
以下是我收到的错误消息:
找不到此页面的资源类。请检查一下 资源文件存在并重试。
描述:执行期间发生了未处理的异常 当前的网络请求。请查看堆栈跟踪了解更多信息 有关错误的信息以及它在代码中的起源。
异常详细信息:System.InvalidOperationException:资源 找不到此页面的类。请检查资源文件 存在并再试一次。
来源错误:
410行:function languageContactPromptPhone(var_lcs){Line 411:if(var_lcs ==&#34; af&#34;){Line 412:return&#39;&lt;%= HttpContext.GetLocalResourceObject(&#34;〜/ GlobalX /输入/ App_LocalResources文件/ InputContactDetails.aspx.resx&#34 ;, &#34; ContactDetails.Text&#34;,new System.Globalization.CultureInfo(&#34; ro&#34;)) %GT;&#39 ;;第413行:}第414行:否则if(var_lcs ==&#34; sq&#34;){
源文件:c:\ inetpub \ wwwroot \ GlobalX \ Input \ InputContactDetails.aspx 行:412
堆栈追踪:
[InvalidOperationException:此页面的资源类不是 找到。请检查资源文件是否存在,然后重试。]
System.Web.Compilation.LocalResXResourceProvider.CreateResourceManager() +2785818 System.Web.Compilation.BaseResXResourceProvider.EnsureResourceManager() +24 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)+23
System.Web.HttpContext.GetLocalResourceObject(String virtualPath, String resourceKey,CultureInfo文化)+38
ASP.input_inputcontactdetails_aspx .__ RenderContentInputContactDetails(HtmlTextWriter的 _:w,Control parameterContainer)在c:\ inetpub \ wwwroot \ GlobalX \ Input \ InputContactDetails.aspx:412
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection孩子)+109
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)+8
System.Web.UI.Control.Render(HtmlTextWriter writer)+10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter适配器)+27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter适配器)+8991378
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)+25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection孩子)+208
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)+8
System.Web.UI.Control.Render(HtmlTextWriter writer)+10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter适配器)+27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter适配器)+8991378
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)+25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection孩子)+208
System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer)+256
System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer)+37
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter适配器)+27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter适配器)+8991378
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)+25
ASP.masterpages_masterinput_master .__ RenderformMasterInput(HtmlTextWriter的 _:w,Control parameterContainer)在c:\ inetpub \ wwwroot \ GlobalX \ MasterPages \ MasterInput.master:140
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection孩子)+109
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter的 作家)+173
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter的 作家)+31
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter输出)+53 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter适配器)+27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter适配器)+8991378
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter的 作家)+40
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection孩子)+208
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)+8
System.Web.UI.Control.Render(HtmlTextWriter writer)+10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter适配器)+27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter适配器)+8991378
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)+25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection孩子)+208
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)+8
System.Web.UI.Page.Render(HtmlTextWriter writer)+29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter适配器)+27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter适配器)+8991378
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)+25
System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) 3060
答案 0 :(得分:3)
Code-Behind中的Asp.Net 4.6中存在相同的错误。这是因为路径中有 App_LocalResources 。
HttpContext.GetLocalResourceObject("~/App_LocalResources/Default.aspx", "SampleResource.Text")
导致错误: 找不到此页面的资源类。请检查资源文件是否存在,然后重试。
没有 / App_LocalResources 就可以了:
HttpContext.GetLocalResourceObject("~/Default.aspx", "SampleResource.Text")
答案 1 :(得分:2)
尝试使用/GlobalX/Input/App_LocalResources/InputContactDetails.aspx.resx,删除〜