I have a problem with GlobalResources
Default I can't use this resources in my MVC project. I tried:
Nie można pobrać właściwości „Name”, ponieważ lokalizacja nie powiodła się. Typ „Resources.Users” nie jest publiczny lub nie zawiera publicznej, statycznej właściwości ciągu o nazwie „FirstName”.
Which its translation is:
Unable to retrieve the properties "Name" as the location failed. Type "Resources.Users" is not a public or does not contain a public static property within named "FirstName."
Then I change User.resx properties:
Now I can't use Resources.User.FirstName I have to useApp_GlobalResources.User.FirstName
I'm happy it's work. But yesterday is my first publish on the test server and resourses not working...
File does't copy to server...
I change User.resx properties
Copy files but the application throws the same previous exception which I shared above and resources not work in localmachine, any advice?
Consider these notes about resources:
When you add a resource file to the App_GlobalResources
special folder of an ASP.NET project, the GlobalResourceProxyGenerator
custom tool will be used for your resource and it will generates an internal
class in Resources
namespace in App_GlobalResources
assembly for managing resource.
They can not be used for data annotations attributes like [Display]
or validation attributes.
They can be used in View or code directly by calling Resources.ResourceFile.ResourceProperty
.
An embedded resource with ResXFileCodeGenerator
as custom tool, will generate a public resource file in a namespace which is default namespace + folder hierarchy.
These kind of resources are public by default but you can change the access modifier of them using designer. Also you can generate them in a custom namespace by changing their Custom Tool Namespace
property.
They can be used for data annotations attributes like [Display]
or validation attributes.
They can be used in View or code directly by calling SomeNamespace.ResourceFile.ResourceProperty
.