Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dmealo/5ee95e3abedf8c788786d10e31ed9441 to your computer and use it in GitHub Desktop.
Save dmealo/5ee95e3abedf8c788786d10e31ed9441 to your computer and use it in GitHub Desktop.
Sitecore Unicorn + InvalidCastException Message: Unable to cast object of type 'System.String' to type 'Unicorn.ControlPanel.Security.IUnicornAuthenticationProvider'

Issue

In your Sitecore instance, you encounter exception stack trace including root exception InvalidCastException Message: Unable to cast object of type 'System.String' to type 'Unicorn.ControlPanel.Security.IUnicornAuthenticationProvider' in logs

2021-11-24 20:13:29 10.240.0.52 GET /sitecore/shell/applications/content-editor ic=Apps%2F48x48%2FPencil.png&he=Content%20Editor&cl=0 80 sitecore\admin 10.240.0.25 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/96.0.4664.45+Safari/537.36 https://accelerator-qa-cm.a61877d1bb744f74981d.eastus.aksapp.io/sitecore/shell/default.aspx 500 0 0 14015
ManagedPoolThread #9 20:13:20 INFO  Job started: Sitecore.ListManagement.Operations.UpdateListOperationsAgent
ManagedPoolThread #9 20:13:20 INFO  Job ended: Sitecore.ListManagement.Operations.UpdateListOperationsAgent (units processed: )
36548 20:13:29 ERROR Application error.
Exception: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source: System.Web
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
   at Sitecore.Shell.Applications.ContentManager.ContentEditorPage.OnPreRender(EventArgs e)
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Nested Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Sitecore.Reflection.ReflectionUtil.CreateObject(Type type, Object[] parameters)
   at Sitecore.Configuration.DefaultFactory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)
   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)
   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, Boolean assert)
   at Sitecore.Pipelines.CorePipelineFactory.GetObjectFromType(XmlNode processorNode)
   at Sitecore.Pipelines.CorePipelineFactory.GetProcessorObject(XmlNode processorNode)
   at Sitecore.Pipelines.CoreProcessor.GetMethod(Object[] parameters)
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Shell.Applications.ContentManager.Editor.GetWarnings(Boolean hasSections)
   at Sitecore.Shell.Applications.ContentManager.Editor.Render(RenderContentEditorArgs args, Control parent)
   at Sitecore.Shell.Applications.ContentManager.ContentEditorForm.RenderEditor(Item item, Item root, Control editorsContainer, Boolean showEditor)
   at Sitecore.Shell.Applications.ContentManager.ContentEditorForm.UpdateEditor(Item folder, Item root, Boolean showEditor)
   at Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Update()
   at Sitecore.Shell.Applications.ContentManager.ContentEditorForm.OnPreRendered(EventArgs e)
Nested Exception
Exception: System.TypeInitializationException
Message: The type initializer for 'Unicorn.Configuration.UnicornConfigurationManager' threw an exception.
Source: Unicorn
   at Unicorn.UI.Pipelines.GetContentEditorWarnings.SerializedWarning..ctor()
Nested Exception
Exception: System.InvalidCastException
Message: Unable to cast object of type 'System.String' to type 'Unicorn.ControlPanel.Security.IUnicornAuthenticationProvider'.
Source: Unicorn
   at Unicorn.Configuration.UnicornConfigurationManager..cctor()

Causes / Solutions

  1. Known Unicorn issue; apply the fix described in the issue description
  2. Similar to 1, an errant <authentionProvider> section may be present in your showconfig.aspx in an unexpected order. Ensure that you elimnate the cause of this if present, such as a superfluous .environment.config file (XDT transform file and/or Sitecore patch file).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment