4

I'm getting the following error in Sitecore 10.1 when Installing Unicorn

Unknown connection string. Name: '$(1)'

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.InvalidOperationException: Unknown connection string. Name: '$(1)'

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

[InvalidOperationException: Unknown connection string. Name: '$(1)']
   Sitecore.Configuration.DefaultSettings.GetConnectionString(String connectionStringName) +384
   Sitecore.Configuration.DefaultFactory.CreateFromConnectionStringName(XmlNode configNode, String[] parameters, Boolean assert) +182
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +188
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
   Sitecore.Configuration.DefaultFactory.GetConstructorParameters(XmlNode configNode, String[] parameters, Boolean assert) +161
   Sitecore.Configuration.DefaultFactory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert) +114
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +163
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
   Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert) +703
   Sitecore.Configuration.DefaultFactory.CreateFromReference(XmlNode configNode, String[] parameters, Boolean assert) +170
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +116
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
   Sitecore.Configuration.DefaultFactory.GetInnerObject(XmlNode paramNode, String[] parameters, Boolean assert) +842
   Sitecore.Configuration.DefaultFactory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper) +545
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +326
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
   Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert) +703
   Sitecore.Configuration.DefaultFactory.GetDatabase(String name, Boolean assert) +157
   Sitecore.Configuration.DefaultFactory.GetDatabase(String name) +55
   Sitecore.Configuration.DefaultFactory.GetDatabases() +121
   Sitecore.Data.SqlServer.SqlServerLinkDataProviderFactory.CreateProvidersForAllDatabases() +161

[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.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +269
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +146
   Sitecore.Reflection.ReflectionUtil.CallStaticMethod(String typeName, String methodName, Object[] parameters) +165
   Sitecore.Configuration.DefaultFactory.CreateFromFactoryMethod(XmlNode configNode, String[] parameters, Boolean assert) +534
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +91
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
   Sitecore.Configuration.DefaultFactory.GetConstructorParameters(XmlNode configNode, String[] parameters, Boolean assert) +161
   Sitecore.Configuration.DefaultFactory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert) +114
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +163
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
   Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert) +703
   Sitecore.Configuration.DefaultFactory.GetLinkDatabase() +36
   Sitecore.DefaultGlobals.Load() +294
   (Object , Object ) +55
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +490
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +236
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Nexus.Web.HttpModule.Application_Start() +146
   Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app) +898
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +584
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724

4 Answers 4

8

Had the same issue due to the SC Hackathon 2021 with Sitecore v. 10.1. Resolved by change this resolved by change this config Unicorn.DataProvider.config section:

<databases>
        <database id="master">
            <dataProviders>
                <dataProvider ref="dataProviders/main">
                    <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
                </dataProvider>
            </dataProviders>
        </database>
        <database id="core">
            <dataProviders>
                <dataProvider ref="dataProviders/main">
                    <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
                </dataProvider>
            </dataProviders>
        </database>
</databases>

With this

<databases>
        <database id="master">
            <dataProviders>
                <dataProvider>
                    <param desc="headProvider">
                        <dataProvider ref="dataProviders/main" param1="$(id)">
                            <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
                        </dataProvider>
                    </param>
                </dataProvider>
            </dataProviders>
        </database>
        <database id="core">
            <dataProviders>
                <dataProvider>
                    <param desc="headProvider">
                        <dataProvider ref="dataProviders/main" param1="$(id)">
                            <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
                        </dataProvider>
                    </param>
                </dataProvider>
            </dataProviders>
        </database>
</databases>

In that case, you needn't add additional attributes in the config, and this easiest to support.

Updates:

As mentioned Mark Cassidy♦ this fix has been included in the new Unicorn Release.

2
  • 1
    I can confirm this solution is correct. It has been tried and tested and has been included in the 4.1.4 release of Unicorn. github.com/SitecoreUnicorn/Unicorn/releases/tag/4.1.4
    – Mark Cassidy
    Mar 9, 2021 at 13:32
  • I tried to solve this exactly this way, but I am still running into this issue. I double and triple checked the modification, restarted IIS, pools, server ... no way. Strange enough: My deployment works in a docker container but not on productive iis server Apr 27, 2021 at 8:29
1

I'm not sure if it is a best way to resolve the issue, but this is what I did to fix it

I have made following changes to Unicorn.DataProvider.config

Change the following lines in Default config

<unicorn type="Unicorn.Data.DataProvider.Unicorn$(database)DataProvider, Unicorn">
    <param connectionStringName="$(1)"/>
    <Name>$(1)</Name>
</unicorn>

With

<unicornMaster type="Unicorn.Data.DataProvider.Unicorn$(database)DataProvider, Unicorn">
    <param connectionStringName="master"/>
    <Name>Unicorn Master</Name>
</unicornMaster>

<unicornCore type="Unicorn.Data.DataProvider.Unicorn$(database)DataProvider, Unicorn">
    <param connectionStringName="core"/>
    <Name>Unicorn Core</Name>
</unicornCore>

And

<databases>
    <database id="master">
        <dataProviders>
            <dataProvider ref="dataProviders/main">
                <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
            </dataProvider>
        </dataProviders>
    </database>
    <database id="core">
        <dataProviders>
            <dataProvider ref="dataProviders/main">
                <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
            </dataProvider>
        </dataProviders>
    </database>
</databases>

With

<databases>
    <database id="master">
        <dataProviders>
            <dataProvider ref="dataProviders/main">
                <patch:attribute name="ref">dataProviders/unicornMaster</patch:attribute>
            </dataProvider>
        </dataProviders>
    </database>
    <database id="core">
        <dataProviders>
            <dataProvider ref="dataProviders/main">
                <patch:attribute name="ref">dataProviders/unicornCore</patch:attribute>
            </dataProvider>
        </dataProviders>
    </database>
</databases>

This changes fixed my issue and everything works fine now in Sitecore 10.1

4
  • Hi mahesh, I tried but i received another error "Missing type attribute for dependency 'dataProviderConfiguration'. Specify an assembly-qualified name for your dependency. ". kindly help me out. Mar 5, 2021 at 11:58
  • Hi Ramesh, can you share your config file? Mar 5, 2021 at 19:17
  • 2
    This solution definitely changes more than would be necessary. I would not recommend it,.
    – Mark Cassidy
    Mar 9, 2021 at 8:38
  • Thanks mark, as I said in my answer, I want sure if this was the right solution and I wanted a quick fix for Hackathon. Happy to delete my answer, so it will be less confusing for others Mar 9, 2021 at 20:06
0

I received the following note when updating to the latest version of Unicorn:

**** IMPORTANT NOTE FOR SITECORE VERSION 10.1+ ****

- Sitecore 10.1 introduces a change in the <database> and <dataProviders> sections of the Sitecore configuration.
- There is no easy way to make a patch configuration file that targets both
- Therefore; if you are on Sitecore 10.1 or above, replace
  - Unicorn.DataProvider.config                     (delete it)                                         WITH
  - Unicorn.DataProvider.10.1.config.disabled       (rename it to Unicorn.DataProvider.10.1.config)

ABSOLUTELY DO READ THIS :P

****************************************************

Here's that file: https://github.com/SitecoreUnicorn/Unicorn/blob/master/src/Unicorn/Standard%20Config%20Files/Unicorn.DataProvider.10.1.config.disabled

-2

Please Update Unicorn.Dataprovider.config for 10.1 with below.

<databases>
            <database id="master">
                <dataProviders>
                    <dataProvider>
                        <param desc="headProvider">
                            <dataProvider ref="dataProviders/main" param1="$(id)">
                                <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
                            </dataProvider>
                        </param>
                    </dataProvider>
                </dataProviders>
            </database>
            <database id="core">
                <dataProviders>
                    <dataProvider>
                        <param desc="headProvider">
                            <dataProvider ref="dataProviders/main" param1="$(id)">
                                <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
                            </dataProvider>
                        </param>
                    </dataProvider>
                </dataProviders>
            </database>
        </databases>
1
  • This is a duplicate answer
    – Mark Cassidy
    Mar 9, 2021 at 8:40

Your Answer

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

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