This can be a nasty little surprise. If you are running a program (Microsoft Office in our case) where that program is not a .NET 2.0/3.0/3.5 app, and it calls your DLL which is a .NET 2.0/3.0/3.5 app, then the Visual Studio debugger thinks your DLL is .NET 4.0 and it will display the following error.
There are several ways to address this. The easiest one is to add an app.exe.config file with the following information. This explicitly sets the .NET version and the Visual Studio debugger will then use the .NET 2.0 CLR (which is the CLR for .NET 3.0 and 3.5 too).
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
You normally do not need to do this for normal usage, just for debugging.
Microsoft office config files: Download Excel.exe, Download Powerpnt.exe, Download Winword.exe
Keywords: Unable to break execution. This process is not currently executing the type of code that you selected to debug.


Thanks for that. I stumbled upon this one this morning, and now it's all explained.
In my case it's a DLL used as a plugin by an external application, so unfortunately an app.config won't work as I understand it. In case it helps anyone out, I did discover that if I detach from the process, then attach back again, the debugger works normally. Obviously it's a bit of a pain doing though, though.
Posted by: MikeM | 08/30/2011 at 08:58 PM