Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

localization using resources, dataannotations

$
0
0

Hello, i want to use something like this in my models:

public class RandomModel
{
  [Required(ErrorMessageResourceType = typeof(Resources.ModelValidation), ErrorMessageResourceName = "ResourceEntry")]
  public string MyField { get; set; }
  ...
}

I have two resx with path (root)\Resources

  1. ModelValidation.resx
  2. ModelValidation.ru-RU.resx

in my project json config file i have this dependency:

"Microsoft.AspNetCore.Localization": "1.0.0-rc2-final"


In my startup.cs

public void ConfigureServices(IServiceCollection services)
        {
            ...

            services.AddLocalization(options =>
                    options.ResourcesPath = "Resources");

            services.AddMvc()
                .AddViewLocalization()
                .AddDataAnnotationsLocalization();

... }

And when i attempt to run my app i see this error:

An unhandled exception occurred while processing the request.

MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "VehicleWebService.CheckForm.resources" was correctly embedded or linked into assembly "VehicleWebService" at compile time, or that all the satellite assemblies required are loadable and fully signed.
System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)

TargetInvocationException: Exception has been thrown by the target of an invocation.
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)

As you may undestand i'm using rc2 mvc6.

Folks please help, i tried everything...


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>