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 8338769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:41:50+00:00 2026-06-09T04:41:50+00:00

I configured an ASP.NET MVC 4 Web API project to use StructureMap 2.6.2.0 as

  • 0

I configured an ASP.NET MVC 4 Web API project to use StructureMap 2.6.2.0 as described in this post, but accessing /api/parts returns the following error despite explicitly calling StructuremapMvc.Start(); in Application_Start():

{
  "ExceptionType": "System.ArgumentException",
  "Message": "Type 'MyProject.Web.Controllers.PartsController' does not have
              a default constructor",
  "StackTrace": "   at System.Linq.Expressions.Expression.New(Type type)\r\n 
                    at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType)\r\n   
                    at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)"
}

I implemented IDependencyResolver and IDependencyScope and set the Web API dependency resolver as follows in ~/App_Start/StructureMapMvc.cs:

GlobalConfiguration.Configuration.DependencyResolver =
    new StructureMapHttpDependencyResolver(container);

Why is Web API still complaining about a default consturctor?

  • 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-06-09T04:41:52+00:00Added an answer on June 9, 2026 at 4:41 am

    Turns out the error description is just really bad. StructureMap is being called, but cannot inject a dependent constructor parameter due to a missing connection string.

    Here’s how I fixed it in IoC.cs:

    x.For(typeof(IRepository<>)).Use(typeof(MongoRepository<>))
        .CtorDependency<string>("connectionString")
        .Is(yourConnectionString);
    

    I was doing this (incorrectly):

    x.For<IRepository<SomeEntity>>().Use<MongoRepository<SomeEntity>>();
    

    There really should be a way to output inner StructureMap exceptions when they occur in the Web API.

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

Sidebar

Related Questions

I have configured my Web.Config file as follow in a ASP.NET MVC 2 project:
I'm trying to debug an ASP.NET webapp that's configured to Use Local IIS Web
I have an ASP.NET MVC web app whose controllers use WCF to call into
I use asp.net mvc 2, added webform with reportviewer controls. The web.config file looks
I'm using the Ninject.Web.Mvc (the MVC 2 version) add-on with ASP.NET MVC 2. This
We configured IIS 5 by mappping * to asp.net handler so that ASP.NET MVC
I have an ASP.NET MVC Partial View that contains a Html.TextBox that is configured
I have a ASP.NET MVC page. I Configured a IIS Website and added the
I have an ASP.NET 2.0 ListView control (aka:parent) and configured inside this ListView I
I have an ASP.NET web application that is using forms authentication. Everything is configured

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.