473,216 Members | 1,288 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

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.Resources.ResourceManager

Public ReadOnly Property rscResource() As System.Resources.ResourceManager
Get
If m_rscResources Is Nothing Then
m_rscResources = New
System.Resources.ResourceManager("MyPortalNamespac e.Strings",
System.Reflection.Assembly.GetExecutingAssembly)
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.GetString method I simply use
the tag name to get the translation.

Label1.Text = rscResource.GetString("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.Resources.MissingManifestResourceException was unhandled by user code
Message="Could not find any resources appropriate for the specified
culture or the neutral culture. Make sure
"MyPortalNamespace.Strings.resources" was correctly embedded or linked into
assembly "App_Code.lkep0udn" 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.Resources.ResourceManager(System.Reflection .Assembly.GetExecutingAssembly.GetName.Name
& ".Strings", System.Reflection.Assembly.GetExecutingAssembly)

Same error message (but 'MyPortalNamespace' 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_GlobalResources, 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.GetString("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 5494
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.Resources.ResourceManager

Public ReadOnly Property rscResource() As System.Resources.ResourceManager
Get
If m_rscResources Is Nothing Then
m_rscResources = New
System.Resources.ResourceManager("MyPortalNamespac e.Strings",
System.Reflection.Assembly.GetExecutingAssembly)
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.GetString method I simply use
the tag name to get the translation.

Label1.Text = rscResource.GetString("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.Resources.MissingManifestResourceException was unhandled by user code
Message="Could not find any resources appropriate for the specified
culture or the neutral culture. Make sure
"MyPortalNamespace.Strings.resources" was correctly embedded or linked into
assembly "App_Code.lkep0udn" 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.Resources.ResourceManager(System.Reflection .Assembly.GetExecutingAssembly.GetName.Name
& ".Strings", System.Reflection.Assembly.GetExecutingAssembly)

Same error message (but 'MyPortalNamespace' 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_GlobalResources, 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.GetString("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.HttpContext.GetGlobalResourceObject("My Resx", key ) as string;

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

This means:

Move your resx files to App_GlobalResources directory, and use
System.Web.HttpContext.GetGlobalResourceObject ().

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_GlobalResources-directory.

So then you would refer it: Resources.MyResx.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.HttpContext.GetGlobalResourceObject("St rings", key)
Return Microsoft.VisualBasic.IIf((value Is Nothing), String.Empty, value)
End Function

End Class

/Fredrik

"Emil Christopher Melar" <emil@no_spam_arpanet.no> wrote in message
news:u3**************@TK2MSFTNGP15.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.Resources.ResourceManager

Public ReadOnly Property rscResource() As
System.Resources.ResourceManager
Get
If m_rscResources Is Nothing Then
m_rscResources = New
System.Resources.ResourceManager("MyPortalNamespac e.Strings",
System.Reflection.Assembly.GetExecutingAssembly)
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.GetString method I simply
use the tag name to get the translation.

Label1.Text = rscResource.GetString("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.Resources.MissingManifestResourceException was unhandled by user
code
Message="Could not find any resources appropriate for the specified
culture or the neutral culture. Make sure
"MyPortalNamespace.Strings.resources" was correctly embedded or linked
into assembly "App_Code.lkep0udn" 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.Resources.ResourceManager(System.Reflection .Assembly.GetExecutingAssembly.GetName.Name
& ".Strings", System.Reflection.Assembly.GetExecutingAssembly)

Same error message (but 'MyPortalNamespace' 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_GlobalResources, 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.GetString("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.HttpContext.GetGlobalResourceObject("My Resx",
key ) as string;

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

This means:

Move your resx files to App_GlobalResources directory, and use
System.Web.HttpContext.GetGlobalResourceObject ().

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_GlobalResources-directory.

So then you would refer it: Resources.MyResx.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
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...
1
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 ...
9
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...
3
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? ...
9
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,...
5
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...
12
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
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...
8
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.