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.

有帮助吗?

解决方案

I wrote my own exclusion.

            .ExcludeAssemblies(x =>
                {
                    if (!x.GetName().FullName.StartsWith("Microsoft."))
                    {
                        return x.GetName().Name.Equals("Microsoft");
                    }
                    return true;
                })
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top