I am trying to run an automated Unicorn Sync on one of My Environments. I have the shared secret key in Unicorn.UI.Config after I had tried using the shared Unicorn.Sharedsecret.Config file with the same result in both cases. I am publishing this secret key as an example it's not the one I am using.
Running Unicorn 3.3.0 RC5 / PowerShell ISE version 5.0.10586.117
Below is the script I am using in power shell to debug this issue:
$ErrorActionPreference = 'Stop'
$ScriptPath = Split-Path $MyInvocation.MyCommand.Path
# This is an example PowerShell script that will remotely execute a Unicorn sync using the new CHAP authentication system.
Import-Module $ScriptPath\Unicorn.psm1
# SYNC ALL CONFIGURATIONS
Sync-Unicorn -ControlPanelUrl 'http://[mysite]/unicorn.aspx' -SharedSecret 'zVjWBabXAAA3LHAA1pBuyoWgAAT4rvhhwu6svj5pT0bvAA09gNQHxrrpyTh4ciA' -Configurations @('default')
Below is the error being thrown with stack trace. Note at the end of the trace something about Invoke-WebRequest
I am not sure if this is the root cause:
Unable to cast object of type 'System.String' to type 'Unicorn.ControlPanel.Security.IUnicornAuthenticationProvider'.
Server Error in '/' Application.
Unable to cast object of type 'System.String' to type 'Unicorn.ControlPanel.Security.IUnicornAuthenticationProvider'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the
error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.String' to type
'Unicorn.ControlPanel.Security.IUnicornAuthenticationProvider'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified
using the exception stack trace below.
Stack Trace:
[InvalidCastException: Unable to cast object of type 'System.String' to type 'Unicorn.ControlPanel.Security.IUnicornAuthenticationProvider'.]
Unicorn.Configuration.UnicornConfigurationManager..cctor() +85
[TypeInitializationException: The type initializer for 'Unicorn.Configuration.UnicornConfigurationManager' threw an exception.]
Unicorn.Data.DataProvider.UnicornSqlServerDataProvider..ctor(String connectionString) +28
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +243
Sitecore.Reflection.ReflectionUtil.CreateObject(Type type, Object[] parameters) +77
Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert) +81
Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +100
Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert) +451
Sitecore.Configuration.Factory.CreateFromReference(XmlNode configNode, String[] parameters, Boolean assert) +91
Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +81
Sitecore.Configuration.Factory.GetInnerObject(XmlNode paramNode, String[] parameters, Boolean assert) +738
Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper) +416
Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +198
Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert) +451
Sitecore.Configuration.Factory.CreateObject(String configPath, Boolean assert) +38
Sitecore.Configuration.Factory.GetDatabase(String name, Boolean assert) +105
Sitecore.Configuration.Factory.GetDatabase(String name) +31
Sitecore.Configuration.Factory.GetDatabases() +54
Sitecore.Data.Managers.ItemManager.InitializeEventHandlers() +24
(Object , Object[] ) +85
Sitecore.Pipelines.PipelineMethod.Invoke(Object[] parameters) +36
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +365
Sitecore.Pipelines.Loader.InitializeManagers.Process(PipelineArgs args) +38
(Object , Object[] ) +56
Sitecore.Pipelines.PipelineMethod.Invoke(Object[] parameters) +36
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +365
Sitecore.Pipelines.CorePipeline.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +158
Sitecore.Nexus.Web.HttpModule.Application_Start() +165
Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app) +498
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +534
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9946024
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1069.1
At C:\Website\data\Unicorn\Unicorn.psm1:56 char:12
+ ... $result = Invoke-WebRequest -Uri $url -TimeoutSec 360 -UseBasicPars ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Unicorn.UI.config looks like:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<unicorn>
<!--
Authentication Provider
Provides a security protocol to determine who has access to the Unicorn Control Panel
-->
<authenticationProvider type="Unicorn.ControlPanel.Security.ChapAuthenticationProvider, Unicorn">
<SharedSecret></SharedSecret>
<ChallengeDatabase>web</ChallengeDatabase>
</authenticationProvider>
<!--
Legacy provider: this provides Unicorn 2.x and 3.0.x behavior for the security token. Deprecated.
<authenticationProvider type="Unicorn.ControlPanel.Security.LegacyAuthenticationProvider, Unicorn" />
-->
</unicorn>
How it appears in sitecore/admin/showconfig.aspx
One thing to add. I have tried the sync locally through the Unicorn's web UI before trying to implement any of this. It worked fine. This issue only arose when I attempted to define a shared secret key to be able to use the API tool.
Any help or comments are greatly appreciated
Unicorn.dll
in your bin folder? Do you see anyCould not create...
messages in your log files?