troubleshooting Question

My WeApp works fine but then 10 or 20 minutes later it fall. Because Microsoft Unity (v3.0) don't have a registered class to match with some interface..

Avatar of foxhardx
foxhardxFlag for Peru asked on
Microsoft IIS Web ServerASP.NET
5 Comments1 Solution418 ViewsLast Modified:
The problem happens when the web is deployed in the server. I don't know maybe the session issue or something like that...

I'm using Unity 3.0 as IOC and Asp.net Mvc5....In my local pc all works fine...when I deploy the solution in a server with IIS7. All works fine, but 10 or 20 minutes later unity don't recognize the matches types... If I stop the server and start again the problems happens again.

--------------------------------------------------------------------------------------------------------------------------------------------
I'm using the unity controller factory:

public class UnityControllerFactory : IControllerFactory
    {
        private IUnityContainer _container;
        private IControllerFactory _innerFactory;

        public UnityControllerFactory(IUnityContainer container)
            : this(container, new DefaultControllerFactory())
        {
        }

        public IController CreateController(RequestContext requestContext, string controllerName)
        {
            try
            {
                return _container.Resolve<IController>(controllerName);
            }
            catch (Exception ex)
            {
                return _innerFactory.CreateController(requestContext, controllerName);
            }
        }

        public void ReleaseController(IController controller)
        {
            _container.Teardown(controller);
        }

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

       
        protected UnityControllerFactory(IUnityContainer container, IControllerFactory innerFactory)
        {
            _container = container;
            _innerFactory = innerFactory;
        }
--------------------------------------------------------------------------------------------------------------------------------------------

This is my UnityConfig

public static void RegisterComponents()
{
    var container = new UnityContainer();
    AppInjections.Register(container);
    DependencyResolver.SetResolver(new UnityDependencyResolver(container));
    var factory = new UnityControllerFactory(container);
    ControllerBuilder.Current.SetControllerFactory(factory);
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This is my controller:

public class MyController : Controller
{
        private GeneratorAlpha _generator;
        private FinderBeta _finder;

        public MyController (GeneratorAlpha generator, FinderBeta finder)
        {
            _generate = generator;
            _finder = finder;
        }

        public ActionResult Index()
        {
            return View();
        }
}
ASKER CERTIFIED SOLUTION
foxhardx

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros