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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:29:44+00:00 2026-06-01T18:29:44+00:00

I am in the process of integrating StructureMap into my MVC3 application. I am

  • 0

I am in the process of integrating StructureMap into my MVC3 application. I am running into a problem where my custom ControllerFactory is throwing an exception when attempting to create a controller:

StructureMap Exception Code: 200 Could not find an Instance named
“contentpage” for PluginType System.Web.Mvc.IController

Here’s what I have in the container:

Controller (System.Web.Mvc.Controller)
Scoped as: Transient

AuctionCMS.Web.Controllers.HomeController, AuctionCMS.Web,
Version=1.0.0.0, Culture=neutral,

AuctionCMS.Web.Controllers.ContentPageController, AuctionCMS.Web,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Configured
Instance of AuctionCMS.Web.Controllers.ContentPageController,
AuctionCMS.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

I did notice that the controller factory is requesting “contentpage” instead of “contentpagecontroller.” Is this correct behavior? What is going wrong?

Here’s my code:

    private void InitStructureMap()
    {
        var container = new StructureMap.Container();

        DependencyResolver.SetResolver(new StructureMapContainer(container));
        ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory(container));

        PerformRuntimeDepdendencyConfiguration(container);
    }



    private void PerformRuntimeDepdendencyConfiguration(IContainer container)
    {
        container.Configure(x => x.Scan(y =>
        {
            y.TheCallingAssembly();
            y.WithDefaultConventions();
            y.LookForRegistries();
            y.AddAllTypesOf<Controller>();
        }));
    }



public class StructureMapContainer : IDependencyResolver
{
    static IContainer _container;

    public StructureMapContainer(IContainer container)
    {
        _container = container;
    }

    public object GetService(Type serviceType)
    {
        if (serviceType.IsAbstract || serviceType.IsInterface)
        {
            return _container.TryGetInstance(serviceType);
        }
        else
        {
            return _container.GetInstance(serviceType);
        }
    }

    public IEnumerable<object> GetServices(Type serviceType)
    {
        return _container.GetAllInstances<object>().Where(s => s.GetType() == serviceType);
    }
}


    public class StructureMapControllerFactory : IControllerFactory
    {
        private readonly IContainer _container;

        public StructureMapControllerFactory(IContainer container)
        {
            _container = container;
        }

        public IController CreateController(RequestContext requestContext, string controllerName)
        {
            System.Diagnostics.Debug.WriteLine(_container.WhatDoIHave()); 

            return _container.GetInstance<IController>(controllerName.ToLowerInvariant());
        }

        public SessionStateBehavior GetControllerSessionBehavior(RequestContext requestContext, string controllerName)
        {
            return SessionStateBehavior.Default;
        }

        public void ReleaseController(IController controller)
        {
            return;
        }
    }

public class ApplicationRegistry : Registry
{
    public ApplicationRegistry()
    {
        ... register some types ...
    }
}
  • 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-01T18:29:45+00:00Added an answer on June 1, 2026 at 6:29 pm

    Like you noted in comments, your controllers aren’t registered by name. Try this:

    container.Configure(x => x.Scan(y =>
    {
        y.TheCallingAssembly();
        y.WithDefaultConventions();
        y.LookForRegistries();
        y.AddAllTypesOf<Controller>()
             .NameBy(type => type.Name.Replace("Controller", "")
             .ToLowerInvariant());
    }));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am in the process of integrating In-App Billing in my application for unmanaged
I am in the process of integrating our custom web app with QuickBooks Enterprise
I'm in the process of integrating certain functionality into a WordPress site. I'm looking
I'm in the process of integrating stripe.js into my app. I'm doing something like:
The process is not running as WOW64, its running as x64 in an x64
I'm integrating some code into my library. It is a complex data structure well
I am integrating my extension with Plimus by batch process. It requires Buy Anywhere
I am in the process of re-developing an application that was started in PHP
I am working on a very large application that has multiple processes running simultaneously;
I had a developer work on integrating Foursquare into my app (which makes me

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.