locked
The resource object with key was not found ... RRS feed

  • Question

  • User1976676925 posted

    Hi, I cannot this problem named in topic. Applcation isn't possible running. Build succes but in start application is this problem:

    1/13/2014 6:44:44 PM System.Web.HttpParseException (0x80004005): The resource object with key 'lblPassword.Text' was not found. ---> System.Web.HttpParseException (0x80004005): The resource object with key 'lblPassword.Text' was not found. ---> System.Web.HttpException (0x80004005): The resource object with key 'lblPassword.Text' was not found.
       at System.Web.Compilation.ResourceExpressionBuilder.ParseExpression(String expression, Type propertyType, ExpressionBuilderContext context)
       at System.Web.UI.BoundPropertyEntry.ParseExpression(ExpressionBuilderContext context)
       at System.Web.UI.ControlBuilder.FillUpBoundPropertyEntry(BoundPropertyEntry entry, String name)
       at System.Web.UI.ControlBuilder.AddBoundProperty(String filter, String name, String expressionPrefix, String expression, ExpressionBuilder expressionBuilder, Object parsedExpressionData, Boolean generated, String fieldName, String formatString, Boolean twoWayBound, Boolean encode, Int32 line, Int32 column)
       at System.Web.UI.ControlBuilder.AddBoundProperty(String filter, String name, String expressionPrefix, String expression, ExpressionBuilder expressionBuilder, Object parsedExpressionData, String fieldName, String formatString, Boolean twoWayBound, Boolean encode, Int32 line, Int32 column)
       at System.Web.UI.ControlBuilder.PreprocessAttribute(String filter, String attribname, String attribvalue, Boolean mainDirectiveMode, Int32 line, Int32 column)
       at System.Web.UI.ControlBuilder.PreprocessAttributes(ParsedAttributeCollection attribs)
       at System.Web.UI.ControlBuilder.Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String id, IDictionary attribs)
       at System.Web.UI.ControlBuilder.CreateBuilderFromType(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String id, IDictionary attribs, Int32 line, String sourceFileName)
       at System.Web.UI.ControlBuilder.CreateChildBuilder(String filter, String tagName, IDictionary attribs, TemplateParser parser, ControlBuilder parentBuilder, String id, Int32 line, VirtualPath virtualPath, Type& childType, Boolean defaultProperty)
       at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)
       at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
       at System.Web.UI.TemplateParser.ProcessException(Exception ex)
       at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
       at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
       at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
       at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
       at System.Web.UI.TemplateParser.ParseInternal()
       at System.Web.UI.TemplateParser.Parse()
       at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
       at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
       at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
       at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
       at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
       at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
       at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
       at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
       at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
       at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
       at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
       at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    

    My files have following content:

    web.config 

      <system.web>
        <compilation targetFramework="4.5" debug="true" />
        <httpRuntime targetFramework="4.5" />
    
        <globalization uiCulture="en-US" culture="en-US"/>
    
      </system.web>

    App_LocalResources\Register.aspx.en-US.resx

    contains key(Name) lblPassword.Text

    value is Password

    <img>http://i.imgur.com/aKGHo41.jpg</img>

    Global.asax.cs

            protected void Application_BeginRequest(object sender, EventArgs e)
            {
                HttpCookie cookie = null;
                string value = Request.QueryString["culture"];
                if (value == null)
                {
                    cookie = Request.Cookies["Culture"];
                    if (cookie != null)
                    {
                        value = cookie.Value;
                    }
                }
                if (value != null)
                {
                    System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(value);
                    System.Threading.Thread.CurrentThread.CurrentCulture = culture;
                    System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
                }
            }

     

    Register.aspx

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="MasonryDM.Pages.register" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    
      <asp:Label ID="lblName" runat="server" Text="<%$ Resources: lblPassword.Text %>">
    
    </asp:Content>
    

     

    I solve this all day but isn't possible for me. Thanks. 

    Monday, January 13, 2014 2:20 PM

Answers

  • User-1509636757 posted

    At least one resource file has to be non-culture-specific. That file has to have a matching .designer file. That is one resource file need to be without the .language extension.

    Here is my finding:

    I created a label:

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Label ID="lblName" runat="server" Text="<%$ Resources: lblPassword.Text %>"></asp:Label>
        </div>
        </form>
    </body>
    </html>

    Set the web.config:

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.5"/>
        <httpRuntime targetFramework="4.5"/>
        <globalization uiCulture="en-US" culture="en-US"/>
    
      </system.web>
    </configuration>

    Created two .resx files as below:

    And the result I got is "Password", That is because I have explicitly set the culture as en-US. However, to make it work, I have to have a resource file in my solution for each aspx/ascx which is not language specific and matching the aspx/ascx file name. I would suggest to use that resource file as default culture resource file like en-US instead of creating specific resource file for en-US. I hope that make sense.

    hope it helps./.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 13, 2014 2:39 PM
  • User-1509636757 posted

    On masterpage I have button for change languages but when I click to this buttons so actions Button_Click1 or Button_Click2 aren't call because page isn't valid. In Register.aspx I have Validator to Textfield and I want to only change language.

    I would suggest to set language Button's CausesValidation property to false. Because, that is not required anyway for registration, right?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 14, 2014 10:17 AM

All replies

  • User-1509636757 posted

    At least one resource file has to be non-culture-specific. That file has to have a matching .designer file. That is one resource file need to be without the .language extension.

    Here is my finding:

    I created a label:

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Label ID="lblName" runat="server" Text="<%$ Resources: lblPassword.Text %>"></asp:Label>
        </div>
        </form>
    </body>
    </html>

    Set the web.config:

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.5"/>
        <httpRuntime targetFramework="4.5"/>
        <globalization uiCulture="en-US" culture="en-US"/>
    
      </system.web>
    </configuration>

    Created two .resx files as below:

    And the result I got is "Password", That is because I have explicitly set the culture as en-US. However, to make it work, I have to have a resource file in my solution for each aspx/ascx which is not language specific and matching the aspx/ascx file name. I would suggest to use that resource file as default culture resource file like en-US instead of creating specific resource file for en-US. I hope that make sense.

    hope it helps./.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 13, 2014 2:39 PM
  • User1976676925 posted

    Thanks a lot. I did two changes and now it's works fine. I moved all aspx files into main directory of folder and then I created all resources for all pages. But now I have still one question.

    I have some textfields on pages and on the textfields I have some validators and when I have change language so I cannot language because textfields aren't valid. Can you help wit this problem? 

    Tuesday, January 14, 2014 4:13 AM
  • User-1509636757 posted

    I have some validators and when I have change language so I cannot language because textfields aren't valid. Can you help wit this problem? 

    I did not get you on this part. If you can be more clear would help to get some hint.

    Tuesday, January 14, 2014 4:47 AM
  • User1976676925 posted

    On masterpage I have button for change languages but when I click to this buttons so actions Button_Click1 or Button_Click2 aren't call because page isn't valid. In Register.aspx I have Validator to Textfield and I want to only change language.  

    MasterPage.Master

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="MasonryDM.MasterPage" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Masonry DM</title>
        <asp:ContentPlaceHolder ID="head" runat="server"> </asp:ContentPlaceHolder>
    </head>
    <body>
            <form id="form1" runat="server">
    
                <table id="mainTable">
    
                    <tr>
                        <td colspan="5">
                            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
                        </td>
                    </tr>
    
                    <tr>
                        <td>@2013 Daniel Žažo -
                            <asp:Button ID="lblEnglish" runat="server" OnClick="Button1_Click" Text="English" />
    &nbsp;-
                            <asp:Button ID="lblCzech" runat="server" OnClick="Button2_Click" Text="Czech" />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </body>
    </html>
    

     

    Register.aspx

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="MasonryDM.Pages.register" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    
        <div id="register.contentPage">
    
            <table id="register.table">
                <tr>
                    <td class="register.first.column">
                        <asp:Label ID="lblName" runat="server" Text="<%$ Resources: lblPassword.Text %>"></asp:Label>
                    </td>
                    <td class="register.first.column">
                        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ForeColor="Red" runat="server" ErrorMessage="Enter your name." ControlToValidate="txtName"></asp:RequiredFieldValidator>
                    </td>
                </tr>
    
            </table>
    
            <hr />
    
    
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Button" />
    
        </div>
    
    </asp:Content>
    

    MasterPage.Master.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace MasonryDM
    {
        public partial class MasterPage : System.Web.UI.MasterPage
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                Session["culture"] = "en-US";
                Server.Transfer("~/Language.aspx", true);
            }
    
            protected void Button2_Click(object sender, EventArgs e)
            {
                Session["culture"] = "cs-CZ";
                Server.Transfer("~/Language.aspx", true);
            }
    
        }
    }

    Tuesday, January 14, 2014 7:52 AM
  • User-1509636757 posted

    On masterpage I have button for change languages but when I click to this buttons so actions Button_Click1 or Button_Click2 aren't call because page isn't valid. In Register.aspx I have Validator to Textfield and I want to only change language.

    I would suggest to set language Button's CausesValidation property to false. Because, that is not required anyway for registration, right?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 14, 2014 10:17 AM
  • User1976676925 posted

    Thanks a lot. Now it works fine for me. 

    Tuesday, January 14, 2014 1:47 PM