Unity MVC5

Mar 12, 2014 at 5:40 PM
Hi guys,
I not sure if this is good place to ask this question or not. If not please direct me to right place.

I'm using Repository pattern and using
    AllClasses.FromLoadedAssemblies().Where(x =>
         x.Namespace != null && (x.Namespace.Contains("TM.Service") ||
every thing works at first, but after changing cshtml file or even a js file at run time, (Start debugging or Start without debugging) I get "The type IUserService does not have an accessible constructor." error!
That's driving me crazy, because that was working just a second ago!
When this error occurs, restarting webapp doesn't work or even building project. The only way to get webapp running again is to Rebuild Solution.

btw, my repositories and services are in separate projects.
Mar 14, 2014 at 5:00 AM
This post looks to be similar to what you are seeing where AppDomain.CurrentDomain.GetAssemblies() is not returning all assemblies after bouncing the AppDomain: http://stackoverflow.com/questions/3552223/asp-net-appdomain-currentdomain-getassemblies-assemblies-missing-after-app

You could try changing the call AllClasses.FromLoadedAssemblies() to AllClasses.FromAssembliesInBasePath() so that assemblies on disk are searched instead of loaded assemblies.

Randy Levy
Enterprise Library support engineer
Support How-to
Mar 14, 2014 at 1:37 PM
Another way to get all of thls in the bin folder is using this line of code
Apr 30, 2014 at 1:52 PM
Edited Apr 30, 2014 at 1:52 PM
Thanks guys, and sorry for late reply.

thanks to @randylevy, I managed to fix this issue with initializing a dummy class from services assembly in the Application_Start.
the working code looks likes
 protected void Application_Start()
            //For IoC Sake!
            var dummyRepository = new DummyRepository();
            var dummyService = new DummyService();