Can't get hold of resources in .resx files

S

Shimon Sim

I just started trying localization for my web application.
I have class library as part of solution so I need to globalize / localize
this component too.

I created resource file in the assembly itself - Account.resx - the one that
VS offers.
And wrote code like this.

static ResourceManager stringManager=

new ResourceManager("AccountResources", Assembly.GetExecutingAssembly());



and in method

if (ex.Message.IndexOf("unq_a_AccountName") > 0)

throw new
AccountInformationException(stringManager.GetString("accountWithNameExistsMessage"),
ex);

I get an error that Account.resource is not part of assembly.

Well I have Account.resx and VS2005 doesn't offer .resource.

So what should I do?

Thank you,

Shimon.
 
T

Tim Ferris

Hi Shimon

Whenever I come across resource issues, the majority of the problems
are to do with how you have named the resource file inside your
assembly.

Use the Reflector http://www.aisto.com/roeder/dotnet/ to open your
assembly up and see how the resource file has been named. Odds on it is
your naming that is the problem.

Cheers

Tim
 
S

Steven Cheng[MSFT]

Hi Shimon,

As for accessing resource items in localized resource file(resx ) compiled
in VS 2005 projects, the VS 2005 ide will help automatically generate
resource accessor class to access the resource items. We can call them to
retrieve resource items, e.g:

suppose I have a class library project (named SBI) in vs 2005, and add a
Resouce1.resx file(contains some string items like String1, String2....),
the IDE will help automatically generate the helper class so that we can
access the resource in the Resource1.resx file like below:

string str1 = SBI.Resource1.String1;

Also, we can use the resgen.exe tool to manually create such resource
accessor helper class:

#Resource File Generator (Resgen.exe)
http://msdn2.microsoft.com/en-us/library/ccec7sz1.aspx

Hope this helps.

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.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top