By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 901 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

require help for reading from ressource files

P: n/a
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\DesktopPortalBan ner.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.InternalGetResour ceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents) +1219

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

System.Resources.ResourceManager.InternalGetResour ceSet(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\DesktopPortalBan ner.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\DesktopPortalBan ner.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
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.