November Happy Hour will be moved to Thursday December 5th.

Magnus Stråle
Aug 12, 2010
  9454
(0 votes)

Debugging initialization modules

I have covered the new initialization system as introduced with EPiServer CMS 6 and EPiServer Community 4 in previous blog posts. See http://world.episerver.com/Blogs/Magnus-Strale/Dates/2009/12/The-new-initialization-system---How-to-write-an-initialization-module-and-advanced-topics/ Just back from a long summer vacation, one of the first tasks was related to a new initialization module and I just wanted to do a quick “debug exploration” before starting on the work proper.

However I utterly failed to get the debugger to halt on a breakpoint in the initialization module. After a coffee I realized that the problem was that the initialization modules execute before the debugger actually hooks up to the process due to the initialization code being invoked from the HttpApplication constructor (actually the EPiServer.Global constructor).

However there is a simple workaround:

  1. Open the EPiServerFramework.config file.
  2. Remove the <automaticSiteMapping> section.
  3. Save the file.
  4. Set your breakpoints in VisualStudio.
  5. Start your EPiServer web app from VisualStudio.

You will now get the debugger to break, since the initialization system will now abort on the first invocation and delay execution until the first BeginRequest, and at that stage the debugger is attached and functional.

Note that the file EPiServerFramework.config will be automatically updated so you might want to set it to read-only to avoid having to edit it constantly.

Aug 12, 2010

Comments

Thomas Dane
Thomas Dane Jul 24, 2017 06:21 PM

This just saved me a lot of time. Thanks very much! 

Johan Book
Johan Book Jul 25, 2017 02:50 AM

In recent versions of Episerver the automaticSiteMapping-section has been removed. A working method using IIS start/stop can be found here:

http://jondjones.com/learn-episerver-cms/episerver-developers-guide/episerver-initialization-module/how-to-debug-an-episerver-scheduled-job-or-initialization-module

Please login to comment.
Latest blogs
Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog

I'm running Optimizely CMS on .NET 9!

It works 🎉

Tomas Hensrud Gulla | Nov 12, 2024 | Syndicated blog

Recraft's image generation with AI-Assistant for Optimizely

Recraft V3 model is outperforming all other models in the image generation space and we are happy to share: Recraft's new model is now available fo...

Luc Gosso (MVP) | Nov 8, 2024 | Syndicated blog