JoelBlogs - Joel Jeffery's Microsoft 365 Blog

Microsoft 365, SharePoint, Teams and Office 365 Architecture, Development, Administration and Training

  • Home
    • Sitemap
  • Articles
    • #SPThingADay
    • SharePoint Online
      • SharePoint Online – Drag and Drop and Large File Uploads
    • SharePoint 2016
    • SharePoint 2013
      • Content Database Changes to the AllUserData Table
    • SharePoint 2010
      • Administration
        • Disable CRL Checking
        • Excel 2010 & PowerPivot
        • Limits & Thresholds
        • PeoplePicker AD Errors
        • Recycle Bin Behaviour
        • Renaming a Server
        • Service Pack 1
        • Unattended Installs
        • Uninstall All SharePoint 2010 Solutions via PowerShell
        • User Alert Management
        • Virtualised SharePoint
        • Visio Stencils for Administrators
      • Development
        • Audience Membership Workflow Activity
        • Base Types, Lists & Content Types
        • BCS & Offline Sync
        • Debugger Skipping Lines
        • Development Laptop Spec
        • Enabling JavaScript IntelliSense
        • Event Receivers & Deployment Jobs
        • FavIcons & SPUrl
        • Google Maps Sandbox Web Part
        • Group By Content Type for List Views
        • Locale Stapler / Master or Default Locale
        • Removing Default Editor Parts
        • Sandbox Embedding Resources
        • Solution Sandbox Introduction
        • SPPersistedObject
        • Restoring Deleted SPSites in SP1
        • SPWebConfigModification 1
        • SPWebConfigModification 2
        • STSADM copyappbincontent vs. Install-SPApplicationContent
        • Workflows for Beginners
        • Workflow InitiationData Seralizer
    • SharePoint 2007
      • Alternate Access Mappings
      • Excel Services
      • Excel Services UDFs & Excel Client 2007
      • Experiences from the Field
      • InfoPath & Forms Server
      • Kerberos & SSRS
      • Records Management
      • Web Application Service
      • WSS vs MOSS
  • Training
    • SharePoint Admin Links
  • Downloads
    • Summary Slides for PowerPoint
    • CodePlex Projects
      • Audience Membership Workflow Activity
      • Google Maps Sandbox Web Part
      • Group By Content Type in List Views
      • Locale Stapler / Master or Default Locale
      • SharePoint Outlook Connector
  • Hire Me!
    • MCP Transcript
    • Résumé/CV

Visual Studio 2008 – When Debugging Highlights the Wrong Line

February 10, 2010 by Joel Jeffery

The Twilight Zone

The weirdest problem. You debug your code in Visual Studio, place a break point and try to step through… All of a sudden, Visual Studio seems to go mad and highlights the wrong line. As you step further in it seems to jump almost randomly from one line to the other…. WTF?!!

Well, we’ve just had this problem with one of my clients.

Debugging the Debugger

The problem is sporadic – in other words, it’s always the same areas of the code where we get the issues, but we don’t always need to debug through those areas, so we don’t always notice.

Initially we thought it was debug symbol files (.pdb) being out of date/sync with the assemblies we’re building. This culminated in very lengthy complete teardown, clean and rebuilds, to no avail. Much googling and trial and error and wheelspinning.

A few articles on the internet mention a hotfix (KB937122) for Visual Studio 2005 SP1 that resolves a similar sounding problem, but this nothing relevant to our version of Visual Studio.

The next time the problem occurred, we thought maybe Visual Studio was loading the wrong .pdb files. But no. A check of Debug –> Windows –> Modules shows which symbol files are loaded and from where.

Click to Zoom! Visual Studio 2008 - Modules Window

We tried specifying locations to load symbols from, and even right-clicking modules in the above window, and picking Load Symbols From –> Module Path. None of this worked.

On and off, this has cost my team maybe 5 days of effort in the last couple of weeks.

The Culprit

After a lot of digging around, it transpires that if you tell the compiler to optimise your code, it can screw up the .pdb files; moreover it seems to cause the random stepping from line to line when debugging in Visual Studio 2008. The default setting in Visual Studio 2008 is for Release configurations to be optimised, but Debug configurations to be unoptimised. However, opening up many of our Visual Studio Project files shows something like this:

Click to Zoom! Build Options for Debug in Visual Studio 2008

The Resolution

So, someone, it seems, is guilty of setting the optimise flag on each of our 20-odd projects in Visual Studio. Luckily, we have Team Foundation Server as a source code repository, and I can see exactly who made that change, and when :)

Click to Zoom! Team Foundation Server Version History - Compare Versions

Maybe you’ve found this article via a search engine, in which case I hope I’ve saved you from the pain in the backside this issue caused us.

Filed Under: Development Tagged With: Debug, Debugger, Debugging, Development, PDB Files, Visual Studio 2008

Joel is a full-stack cloud architect who codes. He is a Microsoft Certified SharePoint Online, SharePoint Server and Azure specialist and Microsoft Certified Trainer.
He has over 20 years' experience with SharePoint and the Microsoft .NET Framework.
He's also co-founder of Microsoft Gold Partner JFDI Consulting Ltd. Read More…

Recent Posts

  • Microsoft Flow Tip #1 – Word Templates and Hiding Empty Repeating Sections
  • SharePoint PowerShell Tip #1 – Select-Object and FieldValues
  • Popular Misconceptions – Microsoft Teams relationship with SharePoint
  • Course: Microsoft 365 Certified Teamwork Administrator
  • Audience Targeted Searches in Modern SharePoint Online
MCT 2020-2021
Microsoft Teamwork Administrator Associate
Joel's Acclaim Profile
Joel's Microsoft Profile

Tags

Administration Architecture Certification Cloud Development Information Architecture intranets MCP Microsoft Microsoft Architecture Microsoft Azure migration Mobile Development MOSS MOSS 2007 office365 Office 365 Office 365 PowerShell SaaS SharePoint SharePoint 2010 SharePoint 2010 Training SharePoint 2013 SharePoint Administration SharePoint Administrator SharePoint Architecture SharePoint Designer 2010 SharePoint Developer SharePoint Development SharePoint Online sharepointonline SharePoint Search SharePoint Training SharePoint Videos Silverlight SOA Solution Sandbox SPThingADay TechEd 2007 Training Videos Visual Studio 2010 Windows Phone 7 WSS

Copyright © 2022 Joel Jeffery, SharePoint Architect