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

How to use .RESX or .RESOURCE to retrieve list of strings

P: n/a
I have a web service that needs to return a particular string for one
of its web methods. I would like to manage the strings in a resource
file. I went through a lot of the help provided on the net and can't
seem to get it to work.

Can someone with expertise assure me this is possible as a Web Service
(using C#)?
If so, can someone provide the steps on how to get this working?

Aug 21 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
By the way, I'm doing this through Visual Studio 2005. I hear
that .RESX files are handled by the IDE and don't need to run
RESGEN.exe separately.

Aug 21 '07 #2

P: n/a
On Aug 21, 1:34 pm, nws_rea...@yahoo.com wrote:
By the way, I'm doing this through Visual Studio 2005. I hear
that .RESX files are handled by the IDE and don't need to run
RESGEN.exe separately.
You need to use the ResourceManager class, see if this link gets you
started..

http://www.sliver.com/dotnet/articles/resinweb.aspx

Ron

Aug 21 '07 #3

P: n/a
Thanks for your response. ResourceManager is something I'm struggling
with.
The link you provided, and other sites I've found seem to be targeting
Web applications, not web services, or not 2005 web services.
>From the link you provided
>ResourceManager rm = new ResourceManager("MyApplication.res", Assembly.GetExecutingAssembly())
What is considered to be "MyApplication" when I have a web service and
not a web app. I tried the name of the project, the namespace, the
class ... nothing works. I always get the following error

"Could not find any resources appropriate for the specified culture or
the neutral culture"

Any ideas?
You need to use the ResourceManager class, see if this link gets you
started..

http://www.sliver.com/dotnet/articles/resinweb.aspx

Ron


Aug 21 '07 #4

P: n/a
On Aug 21, 5:39 pm, nws_rea...@yahoo.com wrote:
Thanks for your response. ResourceManager is something I'm struggling
with.
The link you provided, and other sites I've found seem to be targeting
Web applications, not web services, or not 2005 web services.
From the link you provided
ResourceManager rm = new ResourceManager("MyApplication.res", Assembly.GetExecutingAssembly())

What is considered to be "MyApplication" when I have a web service and
not a web app. I tried the name of the project, the namespace, the
class ... nothing works. I always get the following error

"Could not find any resources appropriate for the specified culture or
the neutral culture"

Any ideas?
You need to use the ResourceManager class, see if this link gets you
started..
http://www.sliver.com/dotnet/articles/resinweb.aspx
Ron
MyApplication is the name of the resource that resides in the DLL.
For a DLL, not sure about using Assembly.GetExecutingAssembly(),
another alternative is to use a object type that is defined in the
same DLL as the resources. e.g.

ResourceManager rm = new ResourceManager("MyApplication.res",
typeof(objectInDll).Assembly)

I sometimes create a wrapper object around the resources and place it
in the same DLL, and actually use it as the object in the 'typeof'.

A possibly easier method is to add a Resource RESX file to your DLL
project. This will create a resx file such as Resource1.resx, and
also a designer file such as Resource1.Designer.cs. Add some strings
to the RESX file via the Designer, and then if you right click on the
designer file and click on Code, you will see a generated class that
provides a wrapper and accessors for the strings that you have added.
This should hopefully serve as an example also.

Ron

Aug 22 '07 #5

P: n/a
Thanks again for your response. It looks like I need to do more
reading about the different flavors of web services that can be
created with VS 2005 (I'm a newbie).

I created a project using "File, New, Web Site ..." and chose the
"ASP .NET Web Service" template. This project does not create a DLL
as opposed to using "File, New, Project ...". However, I'm able to
deploy it to the 2003 server and have an application add a reference
to it and use it. The deploying process is done by copying the .asmx
and web.config file and other files in the App_Code folder.

Can I still use resources from a .RESX file in this scenario?
MyApplication is the name of the resource that resides in the DLL.
For a DLL, not sure about using Assembly.GetExecutingAssembly(),
another alternative is to use a object type that is defined in the
same DLL as the resources. e.g.

ResourceManager rm = new ResourceManager("MyApplication.res",
typeof(objectInDll).Assembly)

I sometimes create a wrapper object around the resources and place it
in the same DLL, and actually use it as the object in the 'typeof'.

A possibly easier method is to add a Resource RESX file to your DLL
project. This will create a resx file such as Resource1.resx, and
also a designer file such as Resource1.Designer.cs. Add some strings
to the RESX file via the Designer, and then if you right click on the
designer file and click on Code, you will see a generated class that
provides a wrapper and accessors for the strings that you have added.
This should hopefully serve as an example also.

Ron- Hide quoted text -

- Show quoted text -

Aug 22 '07 #6

P: n/a
On Aug 22, 10:48 am, nws_rea...@yahoo.com wrote:
Thanks again for your response. It looks like I need to do more
reading about the different flavors of web services that can be
created with VS 2005 (I'm a newbie).

I created a project using "File, New, Web Site ..." and chose the
"ASP .NET Web Service" template. This project does not create a DLL
as opposed to using "File, New, Project ...". However, I'm able to
deploy it to the 2003 server and have an application add a reference
to it and use it. The deploying process is done by copying the .asmx
and web.config file and other files in the App_Code folder.

Can I still use resources from a .RESX file in this scenario?
MyApplication is the name of the resource that resides in the DLL.
For a DLL, not sure about using Assembly.GetExecutingAssembly(),
another alternative is to use a object type that is defined in the
same DLL as the resources. e.g.
ResourceManager rm = new ResourceManager("MyApplication.res",
typeof(objectInDll).Assembly)
I sometimes create a wrapper object around the resources and place it
in the same DLL, and actually use it as the object in the 'typeof'.
A possibly easier method is to add a Resource RESX file to your DLL
project. This will create a resx file such as Resource1.resx, and
also a designer file such as Resource1.Designer.cs. Add some strings
to the RESX file via the Designer, and then if you right click on the
designer file and click on Code, you will see a generated class that
provides a wrapper and accessors for the strings that you have added.
This should hopefully serve as an example also.
Ron- Hide quoted text -
- Show quoted text -
Probably can't use the .RESX file in this scenario. You could
possibly create a separate DLL and then access from your other code,
but generally developers will try to avoid deploying source on the web
server and instead deploy dlls.

Check out add-in for VS2005 that will pre-compile the entire web
project to one more DLLs. Here are some details on it..

http://weblogs.asp.net/scottgu/archi...06/429723.aspx

Check out the add-in for Web Application projects also, this has been
helpful

http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

Ron

Aug 22 '07 #7

P: n/a
I'm going to have to publish the web site so I can work with a DLL. I
guess I'll have to deal with the local debugging by creating the DLL
locally too. Thanks for your help!

Aug 22 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.