2

I am running DD4T 2.1 and when setting up the DI container (Autofac) I get the following exception:

An exception of type 'System.ArgumentException' occurred in Autofac.dll but was not handled in user code

Additional information: The type 'DD4T.Mvc.ViewModels.XPM.XpmMarkupService' is not assignable to service 'DD4T.MVC.ViewModels.XPM.IXpmMarkupService'.

Here's the code that does the DI initialization:

protected void Application_Start(object sender, EventArgs e)
        {
            var builder = new ContainerBuilder();
            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            builder.RegisterFilterProvider();
            builder.UseDD4T();
            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            //XmlConfigurator.Configure();
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }

Can anyone guide me on where I've gone wrong?

1

That is correct.

The type DD4T.Mvc.ViewModels.XPM.XpmMarkupService is not assignable to service DD4T.**MVC**.ViewModels.XPM.IXpmMarkupService but it is assignable to DD4T.**Mvc**.ViewModels.XPM.IXpmMarkupService.

One fix is to download the DD4T.DI.Autofac project and modify Mvc.cs RegisterMvc method to correctly register XpmMarkupService as DD4T.Mvc.ViewModels.XPM.IXpmMarkupService.

Compile and reference the updated DD4T.DI.Autofac dll in your project.

3

We got the same error but fixed it by simply reverting DDT4T.MVC5 NuGet package to version 2.0.8.

We are also using Autofac v4.1.0 and Autofac.Mvc5 v 4.0.0

Are there any issues we need to be aware of with this fix?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.