473,656 Members | 2,819 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resource problem after converting from ASP.NET 1.1 to ASP.NET 2.0

All,

I'm having problems with my resource manager in ASP.NET 2.0 after conversion
from ASP.NET 1.1.

Here is a background:

In ASP.NET 1.1
All my user controls and aspx pages inherit from base classes. A base class
includes this property (among others...;-)):

Private m_rscResources As System.Resource s.ResourceManag er

Public ReadOnly Property rscResource() As System.Resource s.ResourceManag er
Get
If m_rscResources Is Nothing Then
m_rscResources = New
System.Resource s.ResourceManag er("MyPortalNam espace.Strings" ,
System.Reflecti on.Assembly.Get ExecutingAssemb ly)
Return m_rscResources
Else
Return m_rscResources
End If
End Get
End Property

In my application root folder I have two files. One strings.resx and one
strings.sv.resx . When I call the rscResource.Get String method I simply use
the tag name to get the translation.

Label1.Text = rscResource.Get String("First name")

In 1.1 this works absolutely fine. However, In 2.0 (after conversion), it's
not working. The error message I get from .NET is:

System.Resource s.MissingManife stResourceExcep tion was unhandled by user code
Message="Could not find any resources appropriate for the specified
culture or the neutral culture. Make sure
"MyPortalNamesp ace.Strings.res ources" was correctly embedded or linked into
assembly "App_Code.lkep0 udn" at compile time, or that all the satellite
assemblies required are loadable and fully signed."

I've tried to dynamically get the current executing assembly name like this:

m_rscResources = New
System.Resource s.ResourceManag er(System.Refle ction.Assembly. GetExecutingAss embly.GetName.N ame
& ".Strings", System.Reflecti on.Assembly.Get ExecutingAssemb ly)

Same error message (but 'MyPortalNamesp ace' is replaced).

I've tried a number of things to work around this, but I still get this
error message. I've tried placing the resource files into different
directories including App_Code, App_GlobalResou rces, application root etc.
None is making it better.

So, here I stand...

I want to clarify that I know how you can use resources in 2.0, but that's
from scratch. I have hundreds and hundreds of places where I use
rscResource.Get String("MyKey") and I really don't feel I want to change all
that now.

Any help and/or suggestions are more than welcome. I'll be happy to assist
with more project details in case you need it.

Thanks in advance,
Fredrik Rodin,

Stockholm, Sweden
Nov 19 '05 #1
2 5520
Fredrik Rodin wrote:
All,

I'm having problems with my resource manager in ASP.NET 2.0 after conversion
from ASP.NET 1.1.

Here is a background:

In ASP.NET 1.1
All my user controls and aspx pages inherit from base classes. A base class
includes this property (among others...;-)):

Private m_rscResources As System.Resource s.ResourceManag er

Public ReadOnly Property rscResource() As System.Resource s.ResourceManag er
Get
If m_rscResources Is Nothing Then
m_rscResources = New
System.Resource s.ResourceManag er("MyPortalNam espace.Strings" ,
System.Reflecti on.Assembly.Get ExecutingAssemb ly)
Return m_rscResources
Else
Return m_rscResources
End If
End Get
End Property

In my application root folder I have two files. One strings.resx and one
strings.sv.resx . When I call the rscResource.Get String method I simply use
the tag name to get the translation.

Label1.Text = rscResource.Get String("First name")

In 1.1 this works absolutely fine. However, In 2.0 (after conversion), it's
not working. The error message I get from .NET is:

System.Resource s.MissingManife stResourceExcep tion was unhandled by user code
Message="Could not find any resources appropriate for the specified
culture or the neutral culture. Make sure
"MyPortalNamesp ace.Strings.res ources" was correctly embedded or linked into
assembly "App_Code.lkep0 udn" at compile time, or that all the satellite
assemblies required are loadable and fully signed."

I've tried to dynamically get the current executing assembly name like this:

m_rscResources = New
System.Resource s.ResourceManag er(System.Refle ction.Assembly. GetExecutingAss embly.GetName.N ame
& ".Strings", System.Reflecti on.Assembly.Get ExecutingAssemb ly)

Same error message (but 'MyPortalNamesp ace' is replaced).

I've tried a number of things to work around this, but I still get this
error message. I've tried placing the resource files into different
directories including App_Code, App_GlobalResou rces, application root etc.
None is making it better.

So, here I stand...

I want to clarify that I know how you can use resources in 2.0, but that's
from scratch. I have hundreds and hundreds of places where I use
rscResource.Get String("MyKey") and I really don't feel I want to change all
that now.

Any help and/or suggestions are more than welcome. I'll be happy to assist
with more project details in case you need it.

Thanks in advance,
Fredrik Rodin,

Stockholm, Sweden


In ASP.NET 2.0 I was facing the very same problem.

I replaced my ResourceManager instance with this:
public static GetString ( string key )
{
string value =
System.Web.Http Context.GetGlob alResourceObjec t("MyResx", key ) as string;

return ( value == null ) ? string.Empty : value;
}

This means:

Move your resx files to App_GlobalResou rces directory, and use
System.Web.Http Context.GetGlob alResourceObjec t ().

Resources are now also compiled in the same manner as datasets, strongly
typed with intellisense.
ASP.NET 2.0 generates a namespace named "Resources" after you stick
files in the App_GlobalResou rces-directory.

So then you would refer it: Resources.MyRes x.MyKey in code behind.

NOTE: Above text is if you want to use resource strings programatically
in code behind. ASP.NET 2.0 has built-in support for using resources in
controls now.

in controls you would replace the whole thing (instead of using a
resource manager instance) by using the meta: attribute as described in
MSDN: http://msdn2.microsoft.com/en-us/library/fw69ke6f

--
Emil Christopher Melar
Nov 19 '05 #2
Thanks, Emil!

Your suggested method solved the problem:-) Since I'm doing VB, here is the
code for my new class:

Public Class ResourceMapper

Public Function GetString(ByVal key As String) As String
Dim value As String =
System.Web.Http Context.GetGlob alResourceObjec t("Strings", key)
Return Microsoft.Visua lBasic.IIf((val ue Is Nothing), String.Empty, value)
End Function

End Class

/Fredrik

"Emil Christopher Melar" <emil@no_spam_a rpanet.no> wrote in message
news:u3******** ******@TK2MSFTN GP15.phx.gbl...
Fredrik Rodin wrote:
All,

I'm having problems with my resource manager in ASP.NET 2.0 after
conversion from ASP.NET 1.1.

Here is a background:

In ASP.NET 1.1
All my user controls and aspx pages inherit from base classes. A base
class includes this property (among others...;-)):

Private m_rscResources As System.Resource s.ResourceManag er

Public ReadOnly Property rscResource() As
System.Resource s.ResourceManag er
Get
If m_rscResources Is Nothing Then
m_rscResources = New
System.Resource s.ResourceManag er("MyPortalNam espace.Strings" ,
System.Reflecti on.Assembly.Get ExecutingAssemb ly)
Return m_rscResources
Else
Return m_rscResources
End If
End Get
End Property

In my application root folder I have two files. One strings.resx and one
strings.sv.resx . When I call the rscResource.Get String method I simply
use the tag name to get the translation.

Label1.Text = rscResource.Get String("First name")

In 1.1 this works absolutely fine. However, In 2.0 (after conversion),
it's not working. The error message I get from .NET is:

System.Resource s.MissingManife stResourceExcep tion was unhandled by user
code
Message="Could not find any resources appropriate for the specified
culture or the neutral culture. Make sure
"MyPortalNamesp ace.Strings.res ources" was correctly embedded or linked
into assembly "App_Code.lkep0 udn" at compile time, or that all the
satellite assemblies required are loadable and fully signed."

I've tried to dynamically get the current executing assembly name like
this:

m_rscResources = New
System.Resource s.ResourceManag er(System.Refle ction.Assembly. GetExecutingAss embly.GetName.N ame
& ".Strings", System.Reflecti on.Assembly.Get ExecutingAssemb ly)

Same error message (but 'MyPortalNamesp ace' is replaced).

I've tried a number of things to work around this, but I still get this
error message. I've tried placing the resource files into different
directories including App_Code, App_GlobalResou rces, application root
etc. None is making it better.

So, here I stand...

I want to clarify that I know how you can use resources in 2.0, but
that's from scratch. I have hundreds and hundreds of places where I use
rscResource.Get String("MyKey") and I really don't feel I want to change
all that now.

Any help and/or suggestions are more than welcome. I'll be happy to
assist with more project details in case you need it.

Thanks in advance,
Fredrik Rodin,

Stockholm, Sweden


In ASP.NET 2.0 I was facing the very same problem.

I replaced my ResourceManager instance with this:
public static GetString ( string key )
{
string value = System.Web.Http Context.GetGlob alResourceObjec t("MyResx",
key ) as string;

return ( value == null ) ? string.Empty : value;
}

This means:

Move your resx files to App_GlobalResou rces directory, and use
System.Web.Http Context.GetGlob alResourceObjec t ().

Resources are now also compiled in the same manner as datasets, strongly
typed with intellisense.
ASP.NET 2.0 generates a namespace named "Resources" after you stick files
in the App_GlobalResou rces-directory.

So then you would refer it: Resources.MyRes x.MyKey in code behind.

NOTE: Above text is if you want to use resource strings programatically in
code behind. ASP.NET 2.0 has built-in support for using resources in
controls now.

in controls you would replace the whole thing (instead of using a resource
manager instance) by using the meta: attribute as described in MSDN:
http://msdn2.microsoft.com/en-us/library/fw69ke6f

--
Emil Christopher Melar


Nov 19 '05 #3

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

Similar topics

2
1762
by: Arjen | last post by:
Hello, I have 2 resource files. The resource files have both inside the name field values. I want to select from the first resource file the records where the name field haves a value between 1 and 25. Now I am doing this: XmlDocument xdResx = new XmlDocument(); xdResx.Load("Resources.resx");
1
4001
by: Namratha Shah \(Nasha\) | last post by:
Hi All, This is a resource file generation tool which converts an xml based resource formats to .net resource file i.e. (.resources) and vice-versa. Today we will see how we will generate ==> .txt files from .resources or .resx files. ==> .resources files from text or .resx files.
9
12982
by: Tom the Canuck | last post by:
A while back I was playing with C++ and made a simple program with a WAV file as a resource. It worked well and was easy to make. I then went on to try this with VB. I had problems. Can this be done in VB? I have VB6 (Visual Studio 6 Enterprise edition).. Any pointers to get me going in the right direction would help. I like to learn on my own. Making a mistake and figuring out where the error was made enhances the learning experience. It...
3
1350
by: Allen | last post by:
I have a CD Visual Basic .NET Resource Kit 1) I wonder if I should reinstall it now that I have VS2005. I still have VS2003 on the machine. 2) Any reason to keep VS2003 on the machine? I had an old solution that I tried to convert to VS2005 and it bombed, so I
9
2832
by: Alf P. Steinbach | last post by:
<what to design a C++ solution for> A Windows API /resource/ is data embedded in the executable, accessed via API functions. A resource is completely identified by the quadruple (id, type, language, file), where (1) id is what, for want of a better name, I'll call a /kludgeon/, (2) type is also a kludgeon, (3) language is a small integer identifying a concrete national language or one of a set of pseudo-languages such as the Windows...
5
2764
by: Daniel | last post by:
Hey guys When you hook an event (c# 2.0 syntax): myEvent += MyMethodToFire; You need to also unsubscribe it to avoid a resource leak so that the object it is in gets garbage collected like so : myEvent -= MyMethodToFire; That's all fine, but when you use visual studio to create events for objects it never creates an unsubscribing reference, so is it puting in resource leaks? Or is this being cleared somewhere that i am not seeing?
12
5261
by: TS | last post by:
i have a need to possibly enable mutli language support. What benefit do i get by using a resource file instead of a custom xml solution? thanks!
3
1328
by: =?Utf-8?B?TGV4?= | last post by:
I have a standard MFC application, every now and then, probably after editing resources or classes it changes the #included statement in the .RC file from resource.h to reasource. I then have to manually edit .RC file to recover. I am using VC2005 on Windows vista ultimate. The project was original ported from VC6 Any idear what could cause this behaviour. Could this be vista releated ?
8
14933
by: raylopez99 | last post by:
I have the latest version of Visual Studio 2008 Professional, which allows you to create resource files (this is the .resx file, no?), unlike the Express version, which does not. I am trying to cut and paste code that MSDN recommends for playing a simple wav file from inside an embedded file, like presumeably the 'resources' file .resx is. I want to embed the .wav file in a 'resource file' since I don't want the user storing the file on...
0
8382
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
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8498
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
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7311
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...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
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();...
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1600
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.