1

Sitecore 9.0.1 (rev. 171219)
SimpleInjector v.4.3.0
Glass.Mapper v.4.5.0.4

Steps To Reproduce:

  • In the Sitecore dashboard I click on the Forms button
  • Click the Create button and select Blank Form
  • On this request I receive a 500 "/formbuilder/load?id=&sc_formmode=new&sc_formlang=&_=1549466629131"
This is the error I receive
The constructor of type FormBuilderController contains the parameter with name 'formRenderingContext' and type IFormRenderingContext that is not registered. Please ensure IFormRenderingContext is registered, or change the constructor of FormBuilderController.

SimpleInjectorConfig:

System.Web.Mvc.IDependencyResolver chainedMvcResolver =
            new ChainedMvcResolver(new SimpleInjectorDependencyResolver(container),
                System.Web.Mvc.DependencyResolver.Current);
        System.Web.Mvc.DependencyResolver.SetResolver(chainedMvcResolver);

ChainedMvcResolver.cs:

public class ChainedMvcResolver : IDependencyResolver
{
    /// existing code
    IDependencyResolver _fallbackResolver;
    IDependencyResolver _newResolver;

    public ChainedMvcResolver(IDependencyResolver newResolver, IDependencyResolver fallbackResolver)
    {
        _newResolver = newResolver;
        _fallbackResolver = fallbackResolver;
    }

    public object GetService(Type serviceType)
    {
        //if (serviceType.Namespace.StartsWith("Sitecore."))
        //{
        //    return _fallbackResolver.GetService(serviceType);
        //}
        object result = null;

        result = _newResolver.GetService(serviceType);
        if (result != null)
        {
            return result;
        }

        return _fallbackResolver.GetService(serviceType);
    }

    public IEnumerable<object> GetServices(Type serviceType)
    {
        if (serviceType.Namespace.StartsWith("Sitecore."))
        {
            return _fallbackResolver.GetServices(serviceType);
        }
        IEnumerable<object> result = Enumerable.Empty<object>();

        result = _newResolver.GetServices(serviceType);
        if (result.Any())
        {
            return result;
        }

        return _fallbackResolver.GetServices(serviceType);
    }
}

I'm registering this via Sitecore pipeline. I have no existing forms, and this is killing my soul. If you notice in the ChainedMvcResolver I have some commented out lines to explicitly check for Sitecore objects. When I implement this I just get a generic 404 instead of the 500 error.

1
  • Had a similar issue when upgrading to 9. We had to remove the simpleinjector stuff and use Microsoft's instead since Sitecore is compatible with that. You can try manually registering, but it is going to be a lot of work to registration everything you need to.
    – RReilley
    Feb 6, 2019 at 17:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.