Question

I have recently added unity to my project and I am looking for a cleaner way to register classes.

I have got to the point where it auto registers fine but attempts to auto register everything. Including Mircrosoft.Web.Mvc which includes several classes that are sealed not allowing it to be registered and therefore throwing a loader exception.

Any help with a standard auto register or exclude.

Any configuration I try even creating my own customer controller factory leads to this exception.

{"Method 'GetControllerSessionBehavior' in type 'Microsoft.Web.Mvc.MvcDynamicSessionControllerFactory' from assembly 'Microsoft.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.":"Microsoft.Web.Mvc.MvcDynamicSessionControllerFactory"}

All help appreciated.

Was it helpful?

Solution

I wrote my own exclusion.

            .ExcludeAssemblies(x =>
                {
                    if (!x.GetName().FullName.StartsWith("Microsoft."))
                    {
                        return x.GetName().Name.Equals("Microsoft");
                    }
                    return true;
                })
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top