Try our conversational search powered by Generative AI!

Delayed publish fails after upgrade


We did some upgrades to our 7.5 EpiServer site last week and now we can't do delayed publish. There seems to be an internal error that wasn't there before the upgrade preventing us from doing the delayed schedule:

System.InvalidOperationException: Nullable object must have a value. at System.Nullable`1.get_Value() at EPiServer.Core.ContentProvider.get_ContentVersionCacheSlidingExpiration() at EPiServer.Core.ContentProvider.AddContentToCache(IContent content, IEnumerable`1 extraCacheDependencies) at EPiServer.Core.ContentProvider.StoreContentsInCache(IEnumerable`1 chunk) at EPiServer.Core.ContentProvider.GetScatteredContents(IEnumerable`1 contentLinks, ILanguageSelector selector) at EPiServer.DefaultContentProvider.ListDelayedPublish() at EPiServer.Core.DefaultContentRepository.<>c__DisplayClass10.b__f(ContentProvider contentProvider) at EPiServer.Core.ContentProviderMap.Iterate(Action`1 contentProviderHandler) at EPiServer.Core.DefaultContentRepository.ListDelayedPublish() at EPiServer.Util.DelayedPublishJob.PublishContent(IContentRepository publicContentRepository, ContentRepository internalContentRepository, JobStatus status) at EPiServer.Util.DelayedPublishJob.ExecuteInternal(IContentRepository publicContentRepository, ContentRepository internalContentRepository) at EPiServer.DataAbstraction.ScheduledJob.<>c__DisplayClass9.b__5()

What I think is weird with this is that the exception is when EpiServer tries to get the value of a nullable type, what's the point of the nullable if you don't check that it has a value before accessing the value? If you do so you can also provide a much better error message than this stack trace which doesn't give me much information what is wrong.

Anyone knows what could be the problem?

Nov 03, 2014 11:03

My guess is that the issue is caused by the following code in ContentProvider:

    private static TimeSpan ContentVersionCacheSlidingExpiration
        if (!ContentProvider._contentVersionCacheTimeout.HasValue)
          Settings instance;
          if (ServiceLocator.Current.TryGetExistingInstance<Settings>(out instance))
            ContentProvider._contentVersionCacheTimeout = new TimeSpan?(Settings.Instance.ContentVersionCacheSlidingExpiration);
            ContentProvider._contentCacheTimeout = new TimeSpan?(Cache.NoSlidingExpiration);
        return ContentProvider._contentVersionCacheTimeout.Value;

The problem here is that if the first HasValue is false and you fail with TryGetExistingInstance you will most likely not set the _contentVersionCacheTimeout and will therefor get a null pointer when returning on the last line.

My guess is that the line "ContentProvider._contentCacheTimeout = ..." should've been "ContentProvider._contentVersionCacheTimeout = ...".

Edited, Nov 03, 2014 12:37
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.