System.Security.Cryptography.CryptographicException occurred in process…

On my SharePoint development machine where I have Visual Studio each morning when I get into work because my PC is left running overnight, I get the following Visual Studio Just-In-Time Debugger appearing on my screen.

This happens because every night SharePoint 2010 recycles the OWSTIMER.EXE process every night. This is to ensure that the timer service doesn’t run into any memory problems.

Recycling the OWSTIMER process is controlled by a service timer job called “Timer Service Recycle” which runs once a day. Mine runs at 6AM.

If you reset the SharePoint Timer Service manually you can make the Visual Studio Just-In-Time Debugger pop up.

If you find this pop up annoying each day then you can disable it.

Disabling in Visual Studio.

According to Microsoft you can disable the Just-In-Time debugger in Visual Studio. I attempted this but it didn’t seem to work. (Maybe I needed to reboot the PC). I’m putting the instructions here just for completeness.

  • Open Visual Studio as Administrator, on the Tools menu, click Options
  • In the Options dialog box, select the Debugging folder.
  • In the Debugging folder, select the Just-In-Time page.
  • In the Enable Just-In-Time debugging of these types of code box, clear the relevant program types: Managed, Native, or Script.

Disabling using Registry

I found this method worked for me.

  • Open up the registry edit. In run type regedit.exe
  • In the Registry Editor window, locate and delete the following registry keys:
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger
    • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
    • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\DbgManagedDebugger
  • Close the Registry Editor window.

Being a developer machine, you might actually want the JIT debugger available, if that is the case then I’d recommend putting up with the pop up once a day.