473,725 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

App_GlobalResou rces & Resources namespace

I've upgraded a .Net 1.1 web app to 2.0 and am having a heck of a time
getting resources to work again. From what I understand if I move my
strings.resx file into the App_GlobalResou rces folder I should magically be
able to reference my strings using the syntax Resources.strin gs.string1.
This isn't working for me. Is there something I'm missing other than moving
the file itself and rebuilding? I get this error:

"The type or namespace name 'strings' does not exist in the namespace
'System.Resourc es' (are you missing an assembly reference?)"

-Brett-

Mar 21 '06 #1
6 23888


Hi,

Thanks for posting at the newsgroup!

ASP.net 2.0 has introduced one code compilation model, very different from
the ASP.net 1.1. For the resource management, ASP.net 2.0 will generate one
namespace Resources for the resources located under the folder
"App_GlobalReso urces". For each resource (string, image etc) at the
resource file, ASP.net will dynamically generate the static property for
each.

For example, we can add one Resource.resx file at the web application
project located under App_GlobalResou rces. Then we define one string called
"MySiteTitl e" at the resoruce designer. Then we can write the code below to
access this string resource:
String mysitename = Resources.Resou rce.MySiteTitle ;

The Resources namespace is dynamically generated by ASP.net 2.0. And the
second part of the resource name is the resx file name. If we chnage the
resource name to HappyANiceDayRe source.resx, ASP.net 2.0 will dynamically
the correspond name and we can access the string resource as below:
String mysitename = Resources.Happy ANiceDayResourc e.MySiteTitle;

This design will be quite easy for us to locate the resource. For your
application migrated from ASP.net 1.1, I'd suggest please change the code
to locate the resources.

In addition, I'd suggest please this article will be of great help for you
to migrate the application from ASP.net 1.1 to ASP.net 2.0:
ASP.NET 2.0 Migration Overview
http://msdn2.microsoft.com/en-us/library/ms227549.aspx

Please feel free to let me know if you have any further question on this
issue.

Have a nice day!

Best Regards,
Wei-Dong XU
Microsoft Support
---------------------------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
---------------------------------------------------------------------------
It is my pleasure to be of any assistance.
Mar 21 '06 #2
I appreciate the effort to help me here, but frankly if you'd read my post
you'd see I am aware of how this is supposed to work. I'm saying it is not
working for me. I'm looking for a little assistance on what I might be
doing wrong. Let me give a little more detail.

When VS05 converted my ASP.Net 1.1 app to 2.0 it created the
App_GlobalResou rces folder and moved my one string resource (resx) file into
it. For some reason I was unable to open the resx file in the designer so I
went ahead and created a new one and copied all of my strings into it (then
deleted the original). My resx file is named strings.en.resx and is located
in the App_GlobalResou rces subfolder.

In my code-behind file if I try to use the syntax:
Resources.strin gs.en.mystring I am getting compilation errors stating
'Resources' does not exist in the current context.

So is there something I'm missing here? VS05 does not appear to be creating
the typed dataset for my string file.

-Brett-

""Wei-Dong XU [MSFT]"" <v-****@online.mic rosoft.com> wrote in message
news:FM******** ******@TK2MSFTN GXA03.phx.gbl.. .


Hi,

Thanks for posting at the newsgroup!

ASP.net 2.0 has introduced one code compilation model, very different from
the ASP.net 1.1. For the resource management, ASP.net 2.0 will generate
one
namespace Resources for the resources located under the folder
"App_GlobalReso urces". For each resource (string, image etc) at the
resource file, ASP.net will dynamically generate the static property for
each.

For example, we can add one Resource.resx file at the web application
project located under App_GlobalResou rces. Then we define one string
called
"MySiteTitl e" at the resoruce designer. Then we can write the code below
to
access this string resource:
String mysitename = Resources.Resou rce.MySiteTitle ;

The Resources namespace is dynamically generated by ASP.net 2.0. And the
second part of the resource name is the resx file name. If we chnage the
resource name to HappyANiceDayRe source.resx, ASP.net 2.0 will dynamically
the correspond name and we can access the string resource as below:
String mysitename = Resources.Happy ANiceDayResourc e.MySiteTitle;

This design will be quite easy for us to locate the resource. For your
application migrated from ASP.net 1.1, I'd suggest please change the code
to locate the resources.

In addition, I'd suggest please this article will be of great help for you
to migrate the application from ASP.net 1.1 to ASP.net 2.0:
ASP.NET 2.0 Migration Overview
http://msdn2.microsoft.com/en-us/library/ms227549.aspx

Please feel free to let me know if you have any further question on this
issue.

Have a nice day!

Best Regards,
Wei-Dong XU
Microsoft Support
---------------------------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no
rights.
---------------------------------------------------------------------------
It is my pleasure to be of any assistance.

Mar 21 '06 #3
Hi Brett,

As for the ASP.NET 2.0 localization and resource handling, it hasn't change
much from the original one. For the resource file, e.g .resx or .txt file,
their file name should not contain any cultureInfo name(such as "en",
"fr-Fr", this is used for the runtime to idenitity them as the same
resource for a specific language/culture.

For example, if we have the following resource files:

MyResources.str ings.resx

MyResources.str ings.en.resx

MyResources.str ings.fr.resx
They're actually a single resource item, just of different
culture/language. At runtime in the code, we just use the following
statement to retrieve value from the above resource file:
Response.Write( Resources.MyRes ources.strings. XXXXX)

(no prefix like "en" or "fr" or....)

and which file to use depend on the current thread's UICulture.

For example, if we add the following code to manually set the thread's
CurrentUICultur e:

============
protected void Page_Load(objec t sender, EventArgs e)
{

System.Threadin g.Thread.Curren tThread.Current UICulture = new
System.Globaliz ation.CultureIn fo("fr-FR");

Response.Write( Resources.MyRes ources.strings. XXXXX)

============

the above code will read the resource string from the
MyResource.stri ngs.fr.resx file.

You can also get some further description in the MSDN document on ASP.NET
global/localization:
#ASP.NET Globalization and Localization
http://msdn2.microsoft.com/en-us/library/c6zyy3s9.aspx

#Walkthrough: Using Resources for Localization with ASP.NET
http://msdn2.microsoft.com/en-us/library/fw69ke6f.aspx

Hope all these help you.
Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Mar 22 '06 #4
It turns out my problem came down to the fact that my resource file was
named simply 'strings.en.res x'. For some reason Visual Studio doesn't deal
with that as documented (in generating the typesafe dataset). If I change
the name to something like MyResources.str ing.en.resx then everything works
as documented.

This was just one of those crazy bang your head against the wall kindof
problems. I was doing everything as documented but apparently chose a name
that either has special meaning or is involved in a bug of some sort.

Thanks for the help...

-Brett-

"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:tr******** ******@TK2MSFTN GXA03.phx.gbl.. .
Hi Brett,

As for the ASP.NET 2.0 localization and resource handling, it hasn't
change
much from the original one. For the resource file, e.g .resx or .txt file,
their file name should not contain any cultureInfo name(such as "en",
"fr-Fr", this is used for the runtime to idenitity them as the same
resource for a specific language/culture.

For example, if we have the following resource files:

MyResources.str ings.resx

MyResources.str ings.en.resx

MyResources.str ings.fr.resx
They're actually a single resource item, just of different
culture/language. At runtime in the code, we just use the following
statement to retrieve value from the above resource file:
Response.Write( Resources.MyRes ources.strings. XXXXX)

(no prefix like "en" or "fr" or....)

and which file to use depend on the current thread's UICulture.

For example, if we add the following code to manually set the thread's
CurrentUICultur e:

============
protected void Page_Load(objec t sender, EventArgs e)
{

System.Threadin g.Thread.Curren tThread.Current UICulture = new
System.Globaliz ation.CultureIn fo("fr-FR");

Response.Write( Resources.MyRes ources.strings. XXXXX)

============

the above code will read the resource string from the
MyResource.stri ngs.fr.resx file.

You can also get some further description in the MSDN document on ASP.NET
global/localization:
#ASP.NET Globalization and Localization
http://msdn2.microsoft.com/en-us/library/c6zyy3s9.aspx

#Walkthrough: Using Resources for Localization with ASP.NET
http://msdn2.microsoft.com/en-us/library/fw69ke6f.aspx

Hope all these help you.
Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

Mar 22 '06 #5
Thanks for your followup Brett,

Yes, I admit that the document still need much improvement since it lacks
good and complete samples or explanation on some common scenario. Anyway,
if you meet any problem, please feel free to post here, we will be happy to
be of assistance.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 23 '06 #6
Crystal
1 New Member
Hi,
I migrated a web application that was created in VS2003 to VS2005.
I am trying to access migrated resources using Resources.Resur ce.Resourcemana ger.GetString(r esourceName), but it says "The name 'Resources' does not exist in the current context"

I have encountered this error before, when i migrated a website to VS2005.
But when i add a resx file to project, it automatically added "resources referance" to my website project. And i was able to use my old resx files, with resources namespace.

But when i do this in the new project i migrated, it does not add "resources referance"

From where and how can i add "resources referance" to my project?
May 2 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
5320
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have private string myArray;
4
1874
by: António Pinho | last post by:
Hi, I have a big problem with an webpart/assembly. i'm trying to connect to sql server but i get the error "Request for the permission of type System.Data.SqlClient.SqlClientPermission, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.". i've searched for it and can't find a clear answer. but one thing i'm sure: permissions. if i change the trust level in the web.config of the sharepoint portal...
13
1005
by: Adam | last post by:
Trying to get an asp.net 2.0 app running and am receiving this error. I see a bunch of people with this error on the net, but no solution: Works fine on my local machine, deployed to a server it yields this message. Failed to map the path '/App_GlobalResources/' Stack trace: at System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull)
0
5691
by: Jody Gelowitz | last post by:
VS2005 Standard Edition WinXP Pro SP2 I have setup a Web project under: http://localhost/myproject/ and have received a "Failed to map the path '/MyProject/App_GlobalResources'." error (details at the bottom of this message). On Friday, I have run through the steps as outlined at: http://www.thejoyofcode.com/Failed_to_map_the_path_App_GlobalResources.aspx This had corrected this problem, but generated another message relating to a
1
2660
by: kurt sune | last post by:
This drives me nuts,I have put a textfile in App_GlobalResources. How do I read it in runtime? I have googled for two days now. GetExecutingAssembly.GetManifestResourceStream("XYZ.xml") returns nothing. Should I put it in App_Data instead? How do I read it from there?
0
3668
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. · When was the first version of .NET released? The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on...
0
1476
by: C. Moya | last post by:
When sites are published, App_GlobalResources seems to be compiled and is not updateable (even though you set "Allow this precompiled site to be updateable"). Is there any way to update global resources without recompiling the whole site??? This seems to negate a whole chunk of the benefits of using the Web Site Project model. I have tried copying the "App_GlobalResources" manually. That doesn't work. I tried deleting the...
4
7258
by: nils.harrison | last post by:
I would like to list/enumerate all the strings in my resources files in an ASP.NET 2.0 web application, for my own personal convenience. I just want to be able to display the information key1 string1 key2 string2 Nothing fancy.
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9179
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.