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

  • Home
  • SEARCH
  • 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 7713911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:59:26+00:00 2026-06-01T01:59:26+00:00

I’m using Unity with an Asp.net MVC 3 app. Here is some code running

  • 0

I’m using Unity with an Asp.net MVC 3 app. Here is some code running in Application_Start…

        UnityContainer container = new UnityContainer();

        new UnityMappings(container).RegisterTypes();

        DependencyResolver.SetResolver(new UnityServiceLocator(container));

The controllers are registered with the UnityMappings instance like so…

IEnumerable<Type> controllerTypes = from t in Assembly.GetExecutingAssembly().GetTypes()
                                            where typeof (IController).IsAssignableFrom(t)
                                            select t;

    foreach (Type t in controllerTypes)
    {
        container.RegisterType(t);
    }

When I request a page I get the following errors… (The last one is specific to the view being requested.)

Activation error occured while trying to get instance of type
IControllerFactory, key “”

Activation error occured while trying to get instance of type
IControllerActivator, key “”

Activation error occured while trying to get instance of type
IViewPageActivator, key “”

Activation error occured while trying to get instance of type
ModelMetadataProvider, key “”

And then strangely, I can click through all the exceptions and the page works absolutely fine! All the other dependencies are resolved just fine.

Its not a Visual Studio issue because it does it in different instances from different machines. I’ve had to turn off breaking on all exceptions so that I can get anything done.

Any ideas?

  • 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-01T01:59:27+00:00Added an answer on June 1, 2026 at 1:59 am

    This error seems to have gone away when I use this…

    DependencyResolver.SetResolver(new UnityDependencyResolver(container));
    

    … where UnityDependencyResolver is defined as…

    public class UnityDependencyResolver : IDependencyResolver
    {
        private readonly IUnityContainer container;
    
        public UnityDependencyResolver(IUnityContainer container)
        {
            this.container = container;
        }
    
        #region IDependencyResolver Members
    
        public object GetService(Type serviceType)
        {
            try
            {
                return container.Resolve(serviceType);
            }
            catch
            {
                return null;
            }
        }
    
        public IEnumerable<object> GetServices(Type serviceType)
        {
            try
            {
                return container.ResolveAll(serviceType);
            }
            catch
            {
                return new List<object>();
            }
        }
    
        #endregion
    }
    

    Before I was using ‘UnityServiceLocator’ which is defined in ‘Microsoft.Practices.Unity’ like this…

    DependencyResolver.SetResolver(new UnityServiceLocator(container));
    

    Is ‘UnityServiceLocator’ not supposed to be used in this way?

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.