require help for reading from ressource files

Discussion in 'ASP .Net' started by Steve B., Feb 26, 2004.

  1. Steve B.

    Steve B. Guest

    Hi all,
    I'm looking for a pretty way to globalize an ASP.Net application.


    I base on the Globalization Architecture for ASP.NET article from the MSDN
    Library.


    If I have a user control named DesktopBanner.ascx (from Portal Starter Kit),
    I added two files in the same directory using the "application resource
    file" template from Visual Studio:

    a.. DesktopBanner.resx à for neutral culture
    b.. DesktopBanner.fr.resx à for French culture

    Both are embedded resources. The two DLL are actually created when
    compiling.


    Both contain this data, having the text localized:

    <data name="Label1.Text" type="System.String, mscorlib, Version=1.0.5000.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089">

    <value>Bonjour</value>

    </data>



    I also set the culture within the global.asax.vb:



    Private Sub Global_AcquireRequestState(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles MyBase.AcquireRequestState

    Thread.CurrentThread.CurrentCulture =
    CultureInfo.CreateSpecificCulture("fr")

    Thread.CurrentThread.CurrentUICulture =
    CultureInfo.CreateSpecificCulture("fr")

    End Sub



    For now, it is fixed, but I will later check the browser preferred language.



    In my control code behind, I added theses lines:

    Protected m_rm As System.Resources.ResourceManager = Nothing



    Private Sub Page_DataBinding(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles MyBase.DataBinding

    m_rm = New System.Resources.ResourceManager(Me.GetType())

    End Sub



    Finally, I changed the .ascx code to get the string:

    <asp:label id="Label1" CssClass="SiteTitle" EnableViewState="false"
    runat="server">

    <%# m_rm.GetString("Label1.Text") %>

    </asp:label>



    Unfortunately, this does not work, getting the beneath Exception:



    Any help would be greatly appreciated.

    Thanks,

    Steve



    (This can be translated into something like "Could not find good resource
    for the specified culture (or the neutral culture) of your assembly. Please
    check if 'DesktopPortalBanner_ascx.resources' is correctly embedded or link
    to the '$$$' assembly")

    Erreur du serveur dans l'application '/PortalAsso'.


    ----------------------------------------------------------------------------
    ----

    Impossible de trouver des ressources appropriées pour la culture spécifiée
    (ou la culture neutre) de votre assembly. Assurez-vous que
    "DesktopPortalBanner_ascx.resources" est correctement incorporé ou lié dans
    l'assembly "utcjamz6". baseName: DesktopPortalBanner_ascx locationInfo:
    ASP.DesktopPortalBanner_ascx resource file name:
    DesktopPortalBanner_ascx.resources assembly: utcjamz6, Version=0.0.0.0,
    Culture=neutral, PublicKeyToken=null

    Description : Une exception non gérée s'est produite au moment de
    l'exécution de la demande Web actuelle. Contrôlez la trace de la pile pour
    plus d'informations sur l'erreur et son origine dans le code.

    Détails de l'exception: System.Resources.MissingManifestResourceException:
    Impossible de trouver des ressources appropriées pour la culture spécifiée
    (ou la culture neutre) de votre assembly. Assurez-vous que
    "DesktopPortalBanner_ascx.resources" est correctement incorporé ou lié dans
    l'assembly "utcjamz6". baseName: DesktopPortalBanner_ascx locationInfo:
    ASP.DesktopPortalBanner_ascx resource file name:
    DesktopPortalBanner_ascx.resources assembly: utcjamz6, Version=0.0.0.0,
    Culture=neutral, PublicKeyToken=null

    Erreur source:



    Ligne 31 : <asp:label id="siteName"
    runat="server" EnableViewState="false" CssClass="SiteTitle"
    DESIGNTIMEDRAGDROP="11"></asp:label>

    Ligne 32 : <asp:label id="Label1"
    CssClass="SiteTitle" EnableViewState="false" runat="server">

    Ligne 33 : <%# m_rm.GetString("Label1.Text") %>

    Ligne 34 : </asp:label>

    Ligne 35 : </td>



    Fichier source : D:\Projects\PortalAsso\PortalAsso\DesktopPortalBanner.ascx
    Ligne : 33

    Trace de la pile:



    [MissingManifestResourceException: Impossible de trouver des
    ressources appropriées pour la culture spécifiée (ou la culture neutre) de
    votre assembly. Assurez-vous que "DesktopPortalBanner_ascx.resources" est
    correctement incorporé ou lié dans l'assembly "utcjamz6".

    baseName: DesktopPortalBanner_ascx locationInfo:
    ASP.DesktopPortalBanner_ascx resource file name:
    DesktopPortalBanner_ascx.resources assembly: utcjamz6, Version=0.0.0.0,
    Culture=neutral, PublicKeyToken=null]

    System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
    culture, Boolean createIfNotExists, Boolean tryParents) +1219

    System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
    culture, Boolean createIfNotExists, Boolean tryParents) +537

    System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
    culture, Boolean createIfNotExists, Boolean tryParents) +537

    System.Resources.ResourceManager.GetString(String name, CultureInfo
    culture) +103

    System.Resources.ResourceManager.GetString(String name) +6

    ASP.DesktopPortalBanner_ascx.__DataBind__control2(Object sender,
    EventArgs e) in
    D:\Projects\PortalAsso\PortalAsso\DesktopPortalBanner.ascx:33

    System.Web.UI.Control.OnDataBinding(EventArgs e) +66

    System.Web.UI.Control.DataBind() +26

    System.Web.UI.Control.DataBind() +86

    System.Web.UI.Control.DataBind() +86

    ASPNET.StarterKit.Portal.DesktopPortalBanner.Page_Load(Object
    sender, EventArgs e) in
    D:\Projects\PortalAsso\PortalAsso\DesktopPortalBanner.ascx.vb:35

    System.Web.UI.Control.OnLoad(EventArgs e) +67

    System.Web.UI.Control.LoadRecursive() +35

    System.Web.UI.Control.LoadRecursive() +98

    System.Web.UI.Control.LoadRecursive() +98

    System.Web.UI.Page.ProcessRequestMain() +731





    ----------------------------------------------------------------------------
    ----

    Informations sur la version : Version Microsoft .NET Framework
    :1.1.4322.573; Version ASP.NET :1.1.4322.573
    Steve B., Feb 26, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick

    default ressource

    Patrick, Nov 25, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    292
    Patrick
    Nov 25, 2003
  2. Olivier Matrot

    Are satellite assemblies only for ressource ?

    Olivier Matrot, Apr 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    416
    Patrice
    Apr 15, 2005
  3. Progman
    Replies:
    0
    Views:
    328
    Progman
    Mar 6, 2006
  4. Rolf Hemmerling
    Replies:
    3
    Views:
    759
    Roger Leigh
    Oct 31, 2003
  5. Patrick Sabin

    setuptools, accessing ressource files

    Patrick Sabin, Oct 2, 2009, in forum: Python
    Replies:
    1
    Views:
    245
    PJ Eby
    Oct 3, 2009
Loading...

Share This Page