MissingManifestResourceException:无法在 ASP.NET 中以发布模式加载 App_LocalResources

MissingManifestResourceException: Could not load App_LocalResources in Release Mode in ASP.NET

我在 MyPage.resx 文件中有资源。 资源具有 BuildAction:嵌入式资源。

我是这样加载的

var rm = new ResourceManager("MyApp.Web.App_LocalResources.MyPage.aspx", Assembly.GetExecutingAssembly());
            RadWindow1.Title = rm.GetString("MyResource");

它加载正常,当你在调试构建中加载它时。 但是,当您在发布版本中加载它时,它会给您错误:

System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyApp.Web.App_LocalResources.MyPage.aspx.resources" was correctly embedded or linked into assembly "App_LocalResources.root.aakngnnt" at compile time, or that all the satellite assemblies required are loadable and fully signed.

我尝试将 BuildAction 更改为“Content”,但随后我在调试构建中也遇到了这个错误。

母版页中这一行发生错误,但我确定,这一行没问题:

<input type="hidden" id="browser" class="<%=Request.Browser.Browser + Request.Browser.MajorVersion%>" />

调用堆栈:

[MissingManifestResourceException: 找不到任何适合指定文化或中性文化的资源。确保“MyPage.aspx.resources”在编译时已正确嵌入或链接到程序集“App_LocalResources.root.dldzdmsy”,或者确保所需的所有附属程序集都是可加载且完全签名的。] System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(字符串文件名) +441 System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo 文化、Dictionary`2 localResourceSets、布尔 tryParents、布尔 createIfNotExists、StackCrawlMark 和 stackMark)+1219 System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) +1008 System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo 文化,布尔 createIfNotExists,布尔 tryParents) +43 System.Resources.ResourceManager.GetObject(字符串名称、CultureInfo 文化、布尔 wrapUnmanagedMemStream) +591 System.Web.Compilation.ResourceExpressionBuilder.GetResourceObject(IResourceProvider resourceProvider, String resourceKey, CultureInfo culture, Type objType, String propName) +33 ASP.mypage_aspx.__RenderContent1(HtmlTextWriter __w, 控制参数Container) +282 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter 编写器,ICollection 子项)+276 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter 编写器,ControlAdapter 适配器)+80 ASP.masterpage_master.__Renderform1(HtmlTextWriter __w, Control parameterContainer) in System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter 编写器,ICollection 子项)+276 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter 作者)+11661287 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter 作者)+47 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter 编写器,ControlAdapter 适配器)+80 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter 作者) +53 ASP.masterpage_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\myapp\fd8c86aa836916\App_Web_masterpage.master.cdcab7d2.tzvi75g-.0.cs:0 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter 编写器,ICollection 子项)+276 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter 编写器,ControlAdapter 适配器)+80 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter 编写器,ICollection 子项)+169 System.Web.UI.Page.Render(HtmlTextWriter 作者)+40 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter 编写器,ControlAdapter 适配器)+80 System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,布尔 includeStagesAfterAsyncPoint)+4239

我该如何解决这个问题?

发生这种情况是因为调用

caption = <%= GetLocalResourceObject("MyResource.Text") %>;

在 js 部分的 aspx 中。

是的,这很奇怪,但事情就是这样发生的。