cd ../blog

Unable to Debug Web Part in Visual Studio 2010 (MOSS 2007)

Breakpoints not being hit when debugging a MOSS 2007 web part with VS2010 — the fix is changing 'Attach To' from Automatic (v4.0) to Managed (v2.0) code.

</>

Hey everyone!

Today I had a problem that kept me busy for 2 hours.

I loaded up an old web part (class library type, built entirely via code) and wanted to debug it. Deployed the web part, activated the feature, confirmed the DLL was in the GAC.

Visual Studio loaded up the solution. Added a breakpoint in the constructor. Attached to process. The red dot was filled — everything looked good.

Started debugging… strange. The web part is displayed but the breakpoint is never hit.

What I Tried (That Didn’t Work)

After 30 minutes of searching with Google’s help:

  • 32/64-bit setting in IIS (Advanced Settings on the web app) → no effect
  • Microsoft.NET\Framework\v4...\ASPNET_REGIIS -ir → no effect
  • IIS basic settings: switch to Classic and V4 → still nothing

Changed everything back to normal and kept looking.

The Fix

To make a long story short:

Go to Tools → Attach to Process → select the W3WP process → before hitting Attach, check the “Attach to” field.

If it says “Automatic: Managed (v4.0) code, T-SQL code” — that’s your problem.

Change it to manual and only select “Managed (v2.0, v1.1, v1.0) code”.

That did it for me! 😄

Happy debugging!