F5 debugging fails for any SharePoint project types using Visual Studio Professional 2012


Recently I had an opportunity to troubleshoot and fix an issue with not being able to perform F5 debugging using Visual Studio Professional 2012 with “any” SharePoint 2013 project types.

We were able to manually attach VS debugger to the SharePoint process (w3wp.exe) and debug it, however, if we press F5 (or DEBUG –> Start Debugging from VS), we see the following message box in VS.

image

Here’s some information on the environment where we were facing this issue.

Visual Studio Professional 2012 version 11.0.50727.1 with Microsoft Office Developer Tools for Visual Studio 2012 ENU version 11.0.60226.0.

Microsoft Team Foundation Server 2013 Update 2 version 12.0.30324.0.

Team Explorer for Microsoft Visual Studio 2013 version 12.0.21005.13.

On debugging this I found that the VS debugger process (msvsmon.exe) couldn’t attach to the w3wp.exe process (I was testing with a Visual WebPart project that runs on w3wp.exe) because it couldn’t load the following debugger component:

Microsoft.Workflow.DebugController, Version=12.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Checking the GAC, I saw an earlier version of this DLL installed.

image

I don’t know the exact reason why this problem happens with SharePoint project types (and only with SharePoint project/item templates, because F5 debugging works fine for other VS project/items templates).  But my best guess is that Office Developer Tools is not looking at the right place to determine which version of Microsoft.Workflow.DebugController it should use at run time.

The fix turned out to be simple.  VS debugger process C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe was trying to load the incorrect version of debug controller (of course, as dictated by Office Developer Tools).  I found there’s configuration file MSVSMON.EXE uses also located in the same path pointed out above C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe.config.  The default entries in this config file is shown below.

<?xml version ="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0.30319" />
        <supportedRuntime version="v2.0.50727" />
        <supportedRuntime version="v1.1.4322" />
    </startup>
    <runtime>
        <loadFromRemoteSources enabled="true"/>
    </runtime>
</configuration>

I just added an <assemblyBinding/> element and redirected calls to 12.0.0.0 version of Microsoft.Workflow.DebugController to 11.0.0.0 version as shown below.

<?xml version ="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0.30319" />
        <supportedRuntime version="v2.0.50727" />
        <supportedRuntime version="v1.1.4322" />
    </startup>
    <runtime>
        <loadFromRemoteSources enabled="true"/>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.Workflow.DebugController" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="12.0.0.0" newVersion="11.0.0.0" />
        </dependentAssembly>
      </assemblyBinding>
    </runtime>
</configuration>

Closed all instances of Visual Studio Professional 2012 and opened it.  Now F5 debugging for all projects (including SharePoint) works like charm!

Hope this helps!

Skip to main content