|
|
|
start date: Tue, 21 Aug 2007 10:19:58 -0700,
posted on: microsoft.public.dotnet.framework.webservices
back
| Thread Index |
|
1
unknown
|
|
2
unknown
|
|
3
unknown
|
|
4
unknown
|
|
5
unknown
|
|
6
unknown
|
|
7
unknown
|
|
8
unknown
|
How to use .RESX or .RESOURCE to retrieve list of strings
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?
Date:Tue, 21 Aug 2007 10:19:58 -0700
Author:
|
Re: How to use .RESX or .RESOURCE to retrieve list of strings
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.
Date:Tue, 21 Aug 2007 11:34:08 -0700
Author:
|
Re: How to use .RESX or .RESOURCE to retrieve list of strings
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
Date:Tue, 21 Aug 2007 14:07:29 -0700
Author:
|
Re: How to use .RESX or .RESOURCE to retrieve list of strings
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
Date:Tue, 21 Aug 2007 15:39:59 -0700
Author:
|
Re: How to use .RESX or .RESOURCE to retrieve list of strings
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
Date:Tue, 21 Aug 2007 17:12:38 -0700
Author:
|
Re: How to use .RESX or .RESOURCE to retrieve list of strings
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 -
Date:Wed, 22 Aug 2007 08:48:31 -0700
Author:
|
Re: How to use .RESX or .RESOURCE to retrieve list of strings
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/archive/2005/11/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
Date:Wed, 22 Aug 2007 09:38:56 -0700
Author:
|
Re: How to use .RESX or .RESOURCE to retrieve list of strings
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!
Date:Wed, 22 Aug 2007 10:52:24 -0700
Author:
|
|
|