jgauffin / griffin.mvccontrib

A contribution project for ASP.NET MVC3
http://blog.gauffin.org/tag/griffin-mvccontrib/
GNU Lesser General Public License v3.0
83 stars 40 forks source link

LocalizedModelValidatorProvider does not contain a constructor that takes 1 arguments #23

Closed oislek closed 11 years ago

oislek commented 11 years ago

Hi

I've been looking around for a decent solution for localizing model validators and your solution seems to be the best around. I can tell you've put a lot of effort into this package and I'm thankful for that. It's strange that it's not built into MVC (especially now in MVC 4), but you can't get everything you wish for can you?

Anyway, I was going to try it out, so I downloaded it through NuGet in Visual Studio 2012 Express RTM, but after adding the code for Global.cs I get this error:

Quote: 'Griffin.MvcContrib.Localization.LocalizedModelValidatorProvider' does not contain a constructor that takes 1 arguments

I tried to remove the "stringProvider", but then I instead got this at run-time:

Quote: Failed to find an 'ILocalizedStringProvider' implementation. Either include one in the LocalizedModelMetadataProvider constructor, or register an implementation in your Inversion Of Control container.

Am I doing something wrong, or is it because I'm using Visual Studio 2012 or something else?

jgauffin commented 11 years ago

Documentation: http://griffinframework.net/docs/mvccontrib/

Click on the localization namespace in the left list.

oislek commented 11 years ago

Thanks

On Fri, Sep 21, 2012 at 7:38 AM, Jonas Gauffin notifications@github.comwrote:

Documentation: http://griffinframework.net/docs/mvccontrib/

Click on the localization namespace in the left list.

— Reply to this email directly or view it on GitHubhttps://github.com/jgauffin/griffin.mvccontrib/issues/23#issuecomment-8754935.

benpriebe commented 11 years ago

That link doesn't work. It seems from your blog posts that azure is not playing nicely. Maybe you could consider moving your documentation to the same place as your source? Github seems to do all this very nicely :)

cristiboariu commented 11 years ago

I too have the same issue with documentation.... Can't open the above link.

nforss commented 11 years ago

Same problem here. I would also like to use what seems like a really nice framework, but this error is preventing me from doing so.

nforss commented 11 years ago

So, I did some tinkering and got it working. As the error message said, I needed to fix the problem through my IoC. I am using NInject, and here is how I did it:

        var resourceManagers = new ResourceManager[1];
        resourceManagers[0] = Validation.ResourceManager;
        kernel.Bind<ILocalizedStringProvider>().To<ResourceStringProvider>()
            .WithConstructorArgument("resourceManager", resourceManagers);

        kernel.Rebind<ModelValidatorProvider>().To<LocalizedModelValidatorProvider>();

"Validation" is the name of my resource file(s) containing the validation messages. After this, nothing is needed in global.asax.cs at all.