Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8702719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:43:22+00:00 2026-06-13T02:43:22+00:00

I have a resource file in a Class Library project. I’m using this resource

  • 0

I have a resource file in a Class Library project. I’m using this resource file to hold various messages the user may end up seeing.

For example, the name of the resource is “InvalidEmailAddress” and the value in the en-US resource file is “Invalid Email Address”.

When I call the ResourceManager’s GetString(string) method I am doing this:

 return resourceManager.GetString("InvalidEmailAddress");

However, this seems really bad to me. What if somebody changes the name of the resource? Now my statement will return a null value.

Is there a way around this issue?

UPDATE: Localization is an important factor here. The resource manager is used in order to ensure I can change the culture and get appropriate string values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:43:23+00:00Added an answer on June 13, 2026 at 2:43 am

    You can instead use an automatically generated class – the magic string constants will be removed from the code and replaced with strongly typed access methods. VS names this file ResourceName.Designer.cs and updates it every time resx is modified in VS.

    Sample of a generated method:

       internal static string String1 {
            get {
                return ResourceManager.GetString("String1", resourceCulture);
            }
    

    Note: while creating this file is the default behavior when you add a new resource in VS, you may have disabled it or you may have tried to use the generated resource outside the assembly. In that case, make sure to set the “Custom Tool” property or resx file to “PublicResXFileCodeGenerator” or “ResXFileCodeGenerator” (later if you use resources only inside a single assembly). (Thanks @dbaseman for comment).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have separated my resource file to another class library and i am using
I have a class library project which contains a java script file libscript.js which
I have a windows application that accesses a file in a class library project.
I have a silverlight class library (not a top-level application) with several user controls
if you have a class library project that acts as ur DAL and it
I have a ASP.NET MVC 2 project. I've created edmx file on the class
I have a Wpf application project called WpfTest which references WpfTestLib (A class library).
I have the following solution structure: Portal.DataAccess -> Class library project with methods against
I have separated my Global resource files to a different class library in my
I added an XML file as an embedded resource in my class library by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.