Let’s Talk

We would love to hear from you. Want to know more about
our services or have any questions? Say Hi!

Null Reference Exception in Sitecore Signing Token Provider

November 21, 2022
Null Reference Exception in Sitecore Signing Token Provider
Ketan Garala
Ketan Garala
CTO, Sitecore MVP

I was performing installing the Sitecore 9.3 instance which has been configured in my local instance. The Sitecore installation was completed successfully but when I tried to launch the Sitecore site with the localhost it is giving me the below error.


[NullReferenceException: Object reference not set to an instance of an object.] Sitecore.Services.Infrastructure.Sitecore.Security.SigningTokenProvider..ctor(UserService userService, ConfigurationSettings configurationSettings, ILogger logger, ISigningProvider signingProvider) +526 Sitecore.Services.Infrastructure.Sitecore.Security.SigningTokenProvider..ctor() +137 Sitecore.Services.Infrastructure.Sitecore.Security.TokenDelegatingHandler..ctor() +35 [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +139 System.Activator.CreateInstance(Type type, Boolean nonPublic) +105 System.Activator.CreateInstance(Type type) +12 Sitecore.Services.Infrastructure.Configuration.TypeLoader.CreateInstance(Type type, ILogger logger) +63 Sitecore.Services.Infrastructure.Configuration.TypeLoader.Load(Type type) +263 System.Linq.WhereSelectArrayIterator`2.MoveNext() +78 System.Linq.WhereEnumerableIterator`1.MoveNext() +236 System.Linq.Buffer`1..ctor(IEnumerable`1 source) +152 System.Linq.Enumerable.ToArray(IEnumerable`1 source) +91 Sitecore.Services.Infrastructure.Web.Http.ServicesConfigurator.Configure(HttpConfiguration config, RouteCollection routes) +735 Sitecore.Services.Infrastructure.Sitecore.Pipelines.ServicesWebApiInitializer.Process(PipelineArgs args) +194 (Object , Object[] ) +74 Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +469 Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22 Sitecore.Nexus.Web.HttpModule.Application_Start() +161 Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app) +767 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +580 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +165 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +267 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +341 [HttpException (0x80004005): Exception has been thrown by the target of an invocation.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +523 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +107

I want to resolve this issue as I want to run my localhost site and wanted to complete the installation process and get the site up and running. But before that, I am facing this object reference which is not allowing me to set an instance.

I have checked my database connection string in connectionstrings.config file and also double-checked with the SQL connection string with the proper username and password. I think it might be some database issue I am facing with my localhost site. But fortunately, all configurations were made correctly.

The deployment had not been done on this site for over 1 year and in that time some hotfixes and prefix configuration updates had been made. The comparison of the bin and config folders showed that all the configurations remain unchanged for that.

But only a specific error occurred by missing one line in the connectionstrings.config file.

<add name="Sitecore.Services.Token.SecurityKey" connectionString="key=XXXxxXXxx11Xx11xxxXxXX1XX1XxXX1X" />

Making this change into the config file, my site could be accessed again.