Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > require help for reading from ressource files

Reply
Thread Tools

require help for reading from ressource files

 
 
Steve B.
Guest
Posts: n/a
 
      02-26-2004
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
setuptools, accessing ressource files Patrick Sabin Python 1 10-03-2009 02:32 PM
Question: How to access the ressource files in a short fashion Progman ASP .Net 0 03-06-2006 05:39 PM
Are satellite assemblies only for ressource ? Olivier Matrot ASP .Net 3 04-15-2005 02:24 PM
default ressource Patrick ASP .Net 0 11-25-2003 07:41 AM
Howto access .RC/.RES Ressource files with portable C++ code ( BCC,MSVC,GNU-C++,OpenWatcom)? Rolf Hemmerling C++ 3 10-31-2003 07:03 PM



Advertisments