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 4034460
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:58:30+00:00 2026-05-20T11:58:30+00:00

This question applies to all projects really, however my demonstrating environment is an MVC3

  • 0

This question applies to all projects really, however my demonstrating environment is an MVC3 app, hence that tag.

I wrote a DisplayNameAttribute-derived class for our MVC2 projects, like so many people have, so I could localise display names in MVC editors and display templates. I lifted the ValidationAttribute localisation code used for the error message so that it behaved in a ‘standard’ way.

Then I noticed that in MVC3 we have the DisplayAttribute, so I dutifully obsoleted my attribute class in the .Net 4 version of my MVC extension framework and changed the model properties in my current project to use this, e.g:

[Display(ResourceType = typeof(Resources.MyResources), Name = "ResourceName")]
public string ModelProperty { get; set; }

Then I run the web app and I get an error similar to this:

System.InvalidOperationException: Cannot retrieve property ‘Name’ because localization failed. Type ‘[Resource Type Here]’ is not public or does not contain a public static string property with the name ‘[Resource Name Here]’.

I use localisation in various places of course, and in class libraries such resources will be typically be marked public. In web applications, however, I will use the App_GlobalResources folder because, well, that’s what it’s for!

The problem here is that the resource accessors that are generated for resx files in this folder are always generated as internal access, with no way of changing it.

So, since DisplayAttribute seems only to look for public members (whereas the localisation code I copied from ValidationAttribute and applied to my own DisplayNameAttribute-deriving type simply looks for static members with either public OR internal visibility), it would appear that DisplayAttribute is off-limits to any MVC web apps that intend to use App_GlobalResources for the localised strings?

Apart from the fact that this is probably a bug in DisplayAttribute, has anybody else hit this problem? What did you do to solve it? Should I honour the usage of DisplayAttribute and change all my resources to be ‘properly’ embedded as in the class library projects, and set them all as public? Or should I ditch DisplayAttribute in favour of my other class that I know works!?

  • 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-05-20T11:58:31+00:00Added an answer on May 20, 2026 at 11:58 am

    You should be able to change the access modifier. In Solution Explorer, double-click your .resx file, then near the top-right of the managed resource editor, change the Access Modifier drop-down from Internal to Public.

    Update

    This might work: Making global resources public

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

Sidebar

Related Questions

Note: Originally this question was asked for PostgreSQL, however, the answer applies to almost
I have a HashMap (although I guess this question applies to other collections) of
(This question specifically in C#, but applies generally to .NET) I have a largish
I suppose this question could just as easily be applied to PHP with regard
This question is kind of an add-on to this question In C#, a switch
This question and answer shows how to send a file as a byte array
This question comes on the heels of the question asked here . The email
This question would probably apply equally as well to other languages with C-like multi-line
This question is a follow up to my previous question about getting the HTML
(This question is over 6 years old and probably no longer has any relevance.)

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.