Skip to content

[DataAnnotations] resx localization not work on RC1 #15794

@kazuk

Description

@kazuk

environment

  • Windows 10 Enterprize N + japanese lang pack
  • Visual Studio 2015 Enterprize (ja-jp localized)

repro steps

  1. create new ASP.NET Web Application project
  2. add Resource.resx
  3. define Password resource
  4. edit ViewModels/Account/LoginViewModel.cs
        [Required]
        [DataType(DataType.Password)]
        [Display( ResourceType = typeof(Resource), Name ="Password")]
        public string Password { get; set; }

run application and go to login page

expected result

Login form field label shown as resource defined text.

actual result

An unhandled exception occurred while processing the request.

InvalidOperationException: ローカライズに失敗したため、プロパティ 'Name' を取得できません。型 'WebApplication1.Resource' がパブリックでないか、'Password' という名前のパブリックで静的な文字列プロパティが含まれていません。

場所 System.ComponentModel.DataAnnotations.LocalizableString.<>c__DisplayClass0.<GetLocalizableValue>b__3()

error was reports WebApplication1.Resource is not public or 'Password' is not public static.

in generated Resources.Designer.cs

    internal class Resource {

 snip

        internal static string Password {
            get {
                return ResourceManager.GetString("Password", resourceCulture);
            }
        }
   }
  • Resource class generated with internal
  • Password property generated with internal static

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions