3 out of 4 times when i build my project, I get NullReferenceException on all pages. This only happens on my dev-environment, but it's really annoying. Anyone who has a solution?
[NullReferenceException: Object reference not set to an instance of an object.]
EPiServer.Data.DataInitialization.InitializeCacheProvider(CacheProvider cacheProvider) +367
EPiServer.Data.DataInitialization.Initialize(InitializationEngine context) +209
EPiServer.Framework.Initialization.ModuleNode.Execute(Action a, String key) +63
EPiServer.Framework.Initialization.InitializationEngine.Initialize(HostType hostType) +168
EPiServer.Framework.Initialization.InitializationModule.Initialize(HostType hostType) +308
EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +75
ASP.global_asax..ctor() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\229e38c1\db99c0d4\App_global.asax.0.cs:0
[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) +117
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +247
System.Activator.CreateInstance(Type type, Boolean nonPublic) +106
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object args, CultureInfo culture, Object activationAttributes) +12738733
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object args, CultureInfo culture) +28
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object args) +83
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +315
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700896
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869125
Feels like this getting worse and worse for every day. Anyone with the samre issue, getting really annying.
We're reporting a bug for this to investigate. Do you have any idea what can be causing this to help us track the issue?
One thing you can try is to set web.config setting optimizeCompilations="false" on compilation element.
I have a feeling that the issue appear if I'm too quick sending the first request after rebuild. The issue might be less common if I wait a couple of seconds before I refresh my browser. I'm not sure about this, it's just a feeling I've got. But once the exception's been thrown, the site is "stuck" with this. Need to either resave web.config or rebulid the project, and it might work after that
Tried to set optimizeCompilations="false", but no difference.
Another thing you could try is to add explicit configuration for episerver.data in your web.config. That is add below line to configSections
<section name="episerver.dataStore" type="EPiServer.Data.Configuration.EPiServerDataStoreSection, EPiServer.Data" />
and then the following block in your web.config file
<episerver.dataStore> <dataStore defaultProvider="EPiServerSQLServerDataStoreProvider"> <providers> <clear/> <add name="EPiServerSQLServerDataStoreProvider" description="SQL Server implementation of Data Store" type="EPiServer.Data.Dynamic.Providers.SqlServerDataStoreProvider, EPiServer.Data" connectionStringName="EPiServerDB" /> </providers> <cache defaultProvider="httpCacheProvider"> <providers> <clear/> <add name="httpCacheProvider" description="Http Cache implementation for DataStore" type="EPiServer.Data.Cache.HttpRuntimeCacheProvider,EPiServer.Data.Cache" /> <add name="nullCacheProvider" description="Null Cache implementation for DataStore" type="EPiServer.Data.Cache.NullCacheProvider,EPiServer.Data" /> </providers> </cache> </dataStore> </episerver.dataStore>
I've tested this for a couple of hours now, and it actually seems to work! Haven't got the crash since I implemented this configuration. Will test a little bit more before I mark as answer.
Just curious, have I made something wrong in my original installation?
I do not think you have done anything wrong. My guess is that we have a timing/race condition bug in our initialization (during initialization we run parts in parallell to speed up initialization) so that in some cases things get wrong. But I have reported a bug for it and we will investigate it.
I am experiencing the same issue on an staging environment, the difference is that after a few page-refresh the site comes back online.
The solution is running on EPiServer 7.1.3
Can you please advice on the status of the bug that was reported back then?
Thanks and Regards,
The bug mentioned by Johan is fixed in EPiServer 7 Patch 4.
Bug #99523: Site throws a NullReferenceException on start up occassionally
Thank you for your prompt reply.
Currently the solution is running on Release 7.1.3, should we still install the patch for Release 7?If so, can you please advise what is the difference between Release 7 Patch X and Release 7.X.Y.
Information about patch 4 can be found here: http://world.episerver.com/Articles/Items/EPiServer-7--Patch-4/
Sorry if I was not clear in the first post. I think the question is: Are Release 7.1.3 and Release 7 Patch 4 related in any way?
Thanks for the clarification. There is no overlap of assemblies between 7.1 and patch 4. EPiServer 7.1 has UI updates (and bug fixes) while patch 4 fixes a bunch of bugs in the core.
So to get the latest and greatest of EPiServer 7 as of now, the solution should be using:
EpiServer 7.1.4 and EPiserver 7 Patch 4.
Yes, unless you want to upgrade to EPiServer 7.5, that should be the case.