如何修复错误:在运行时找不到资源文件?

时间:2017-02-20 08:30:53

标签: asp.net-mvc

我的MVC5项目中有资源文件。

我使用资源文件进行本地化。

这是资源文件的属性窗口:

enter image description here

这是Person class:

public class Person
{
    [Display(Name = "FirstName", ResourceType = typeof(Resources55))]
    [Required(ErrorMessageResourceType = typeof(Resources55),
              ErrorMessageResourceName = "FirstNameRequired")]
    [StringLength(50, ErrorMessageResourceType = typeof(Resources55),
                      ErrorMessageResourceName = "FirstNameLong")]

    public string FirstName { get; set; }

    [Display(Name = "LastName", ResourceType = typeof(Resources55))]
    [Required(ErrorMessageResourceType = typeof(Resources55),
              ErrorMessageResourceName = "LastNameRequired")]
    [StringLength(50, ErrorMessageResourceType = typeof(Resources55),
                      ErrorMessageResourceName = "LastNameLong")]

    public string LastName { get; set; }
}

这是生成Person类的视图:

<div class="form-group">
    @Html.LabelFor(model => model.FirstName, new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.EditorFor(model => model.FirstName)
        @Html.ValidationMessageFor(model => model.FirstName)
    </div>
</div> 

运行时间在此行中:

 @Html.LabelFor(model => model.FirstName, new { @class = "control-label col-md-2" })

我收到此错误:

{"Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure \"MvcInternationalization.App_GlobalResources.Resources55.resources\" was correctly embedded or linked into assembly \"MvcInternationalization\" at compile time, or that all the satellite assemblies required are loadable and fully signed."}

任何想法如何解决错误?

0 个答案:

没有答案