Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6663481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:30:13+00:00 2026-05-26T02:30:13+00:00

I am using fluentvalidation and use structuremap to inject validators for actions in asp.net

  • 0

I am using fluentvalidation and use structuremap to inject validators for actions in asp.net mvc3. I have problems to inject my business objects to validator objects. I get an error like this:

{“StructureMap Exception Code: 202\nNo Default Instance defined for PluginFamily Suggestion.Biz.BO.ISubjectBO, Suggestion.Biz, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”}

How can i inject SubjectBO to SubjectValidator?

SubjectValidator:

public class SubjectValidator : AbstractValidator<SUBJECT>
{
    private ISubjectBO _subjectBO;
    public SubjectValidator(ISubjectBO subjectBO)
    {
        _subjectBO = subjectBO;
        Custom(x=>{
            if(!_subjectBO.CanUpdate(x))
            return new ValidationFailure(null, "error msg");
            return null;
        });
    }
}

SuggestionValidationRegistry:

public class SuggestionValidationRegistry : Registry
{
    public SuggestionValidationRegistry()
    {

        For<IValidator<SUBJECT>>().Singleton().Use<SubjectValidator>();
        ValidatorOptions.ResourceProviderType = typeof(ValidationResources);
    }
}

StructureMapValidatorFactory:

public class StructureMapValidatorFactory : ValidatorFactoryBase
{
    public override IValidator CreateInstance(Type validatorType)
    {

        return ObjectFactory.TryGetInstance(validatorType) as IValidator;
    }
}

App_start:

        ObjectFactory.Configure(cfg => cfg.AddRegistry(new SuggestionValidationRegistry()));
        FluentValidationModelValidatorProvider.Configure(provider => provider.ValidatorFactory = new StructureMapValidatorFactory());
        DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;

Yes i configure at app_start
SuggestionBizRegistry :

public class BizRegistry : Registry
{
    public BizRegistry()
    {
        For<IAwardTypeBO>().Use<AwardTypeBO>();
        For<IQuoteBO>().Use<QuoteBO>();
        For<ISubjectBO>().Use<SubjectBO>();
        For<IContestBO>().Use<ContestBO>();
        For<IApplicationBO>().Use<ApplicationBO>();
        For<IScreenBO>().Use<ScreenBO>();
    }
}

App_start:

protected void Application_Start()
    {
        ConfigureStructureMap();

        AreaRegistration.RegisterAllAreas();

        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);

        EFUnitOfWorkFactory.SetObjectContext(() => new SuggestionModel());


        UnitOfWork.UnitOfWorkFactory = new EFUnitOfWorkFactory();


    }

    private static void ConfigureStructureMap()
    {
        IContainer container = new Container(x =>
        {
            x.For<IControllerActivator>().Use<StructureMapControllerActivator>();
            x.AddRegistry(new BizRegistry());                
        });
        DependencyResolver.SetResolver(new StructureMapDependencyResolver(container));
        ObjectFactory.Configure(cfg => cfg.AddRegistry(new SuggestionValidationRegistry()));
        FluentValidationModelValidatorProvider.Configure(provider => provider.ValidatorFactory = new StructureMapValidatorFactory(container));
        DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:30:14+00:00Added an answer on May 26, 2026 at 2:30 am

    You have not configured constructor parameter ISubjectBO subjectBO when configuring SubjectValidator injection

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have an ASP.NET MVC3 app with model validation using FluentValidation . User enters some
I have an ASP.NET MVC3 website setup using fluent validation and ninject. The validation
I have a FluentValidation validator that I want to use to validate a booking.
I am using ASP.NET MVC 3 and FluentValidation for validating my view models. I
I'm using FluentValidation framework. And at the moment I have several validators (per entity).
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I have been evaluating xVal as framework for validating Entities in the ASP.Net MVC
In which circumstances would you choose FluentValidation (FV) over the ASP.NET MVC 3 way
I am using FluentValidation in my application to verify my entities, but I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.