SaaS CMS has officially launched! Learn more now.

"ClassFactory not initialized" after .NET 4.0 update


I'm updating a CMS6 R1 site from.NET 3.5 to 4.0. Everything seems to work fine, but on site startup I always get this YOD message. If i hit F5 and refresh the page it loads fine, but it seems like the very first request at startup always fails.

Server Error in '/' Application.
ClassFactory not initialized
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: EPiServer.BaseLibrary.ClassFactoryException: ClassFactory not initialized

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:

[ClassFactoryException: ClassFactory not initialized]
   EPiServer.BaseLibrary.ClassFactory.IsRegistered(Type baseType) +187
   EPiServer.CacheManager..cctor() +238

[TypeInitializationException: The type initializer for 'EPiServer.CacheManager' threw an exception.]
   EPiServer.CacheManager.RuntimeCacheGet(String key) +0
   EPiServer.StaticCacheKey.EnsureKey() +17
   EPiServer.DataAbstraction.UnifiedPathInfo..cctor() +45

[TypeInitializationException: The type initializer for 'EPiServer.DataAbstraction.UnifiedPathInfo' threw an exception.]
   EPiServer.DataAbstraction.UnifiedPathInfo.Load(String path) +495
   EPiServer.FileSystem.DefaultAccessControlList..ctor(String path) +71
   EPiServer.Web.Hosting.UnifiedDirectory.get_DirectoryAC() +300
   EPiServer.Web.Hosting.UnifiedDirectory.QueryAccess() +130
   EPiServer.Web.Hosting.UnifiedDirectory.QueryDistinctAccess(AccessLevel access) +27
   EPiServer.Web.Hosting.VirtualPathVersioningProvider.GetDirectory(String virtualPath) +420
   EPiServer.Web.Hosting.VirtualPathHandler.InitializeProviders(ProviderSettingsCollection providers, Boolean captureCustomExceptions) +1784
   EPiServer.Web.InitializationModule.InitializeVirtualPathProviders(VirtualPathElement vpElement) +158
   EPiServer.Web.InitializeEngine.Initialize() +507
   EPiServer.Web.InitializationModule.Initialize(EPiServerSection config, Settings settings, ConnectionStringSettingsCollection connectionStringSettings) +2069
   EPiServer.Web.InitializeEngine.Initialize() +507
   EPiServer.Web.InitializationModule.StaticInitialization() +1717
   EPiServer.Web.InitializationModule.Initialize(InitializationEngine context) +31
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +629
   EPiServer.Framework.Initialization.InitializationEngine.Initialize(HostType hostType) +115
   EPiServer.Framework.Initialization.InitializationModule.StaticInitialization(HostType hostType) +200
   EPiServer.Framework.Initialization.InitializationModule.Application_BeginRequest(Object sender, EventArgs e) +437
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 

After asking Google, I find that most people seemed to have this issue in CMS 5. The solution back then adding ModuleDependency attributes to modules inheriting from IInitializationModule. But this did not work for me, and the still error remains.

Any suggestions on how to proceed?


Apr 30, 2012 10:54

It's usually something in your web.config. Check that the upgrade didn't mess with your config's modules and handlers and also double check that the steps described here were followed:

Which type of web server throws the error?

Edited, May 07, 2012 23:49

I've put this one on hold for now, but I'll double check the steps in the blog post.

The IIS is 7.5. 

May 15, 2012 10:44

I've tried doing the steps in the blog post again, but I still have the same error message.

Additionally, I've tried this nuget package: without any luck. The same error message persists.

I've also double checked that the correct (CMS6) version of System.ComponentModel.Composition.dll is referenced for projects that have initialization modules. 

Edit - Some more info:

  • I've tried moving the modules that are not EPiServer specific above the  Initialization module in web.config, as suggested in this topic: Unfortunately, this did not make any difference.
  • I've also tried commenting out all code in custom modules implementing IInitializableModule. I then tried commenting out all modules from web.config so that the only left were:

<add name="InitializationModule" type="EPiServer.Framework.Initialization.InitializationModule, EPiServer.Framework" preCondition="managedHandler" />
<add name="FirstBeginRequestModule" type="EPiServer.Web.InitializationModule, EPiServer" preCondition="managedHandler" />
<add name="Initializer" type="EPiServer.Scheduler.Initializer, EPiServer.Scheduler" preCondition="managedHandler" />
<add name="WorkflowRuntime" type="EPiServer.WorkflowFoundation.WorkflowSystem, EPiServer.WorkflowFoundation" preCondition="managedHandler" />
<add name="UrlRewriteModule" type="EPiServer.Web.UrlRewriteModule, EPiServer" preCondition="managedHandler" />


I'm running IIS 7.5 with .NET Framework 4 Application Pool in Integrated mode. 

Any other suggestions are appreciated!

Edited, May 21, 2012 16:00

EPiServer support tipped my that I might need to reinstall all EPiServer programs on my development environment. So I reinstalled CMS, Relate and Composer. After that I haven't had any "ClassFactory" YODs yet, so the issue seems to have been resolved.

Im not sure if it's worth to mention but I noticed that my previous EPiServer Shared (in Windows' Programs & Features list) was version 1.1.454.0, while after reinstalling all EPiServer programs it was 1.1.432.0 (so in fact older). Also, I did not install EPiServer SEO this time around (as this was for testing purposes only).

May 31, 2012 9:03
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.