Can't debug threads anymore

since a couple of days, I am unable to debug inside threads with Visual Studio 2005

Something simple like below, leads to the effect, that the first breakpoint inside the thread function is hit, and when I step over, the program throws an C++ exception which is not catched by managed code, disassembly of the exception location is below the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsApplication60
{
public partial class Form1 : Form
{
private Thread myThread = null;
public Form1()
{
InitializeComponent();
myThread =
new Thread(new ThreadStart(Perform));
myThread.Start();
}
public void Perform()
{
int li = 0;
while (li < 100000)
{
++li;
Thread.Sleep(250);
}
}}}

7C920560 jne 7C94BD4D
7C920566 mov al,1
7C920568 call 7C91EE02
7C92056D ret 0Ch <= Exception, always at this location

I have tested this code on different machines, and some have the same problem with debugging it, others have no problem, so it seems PC related.

I was wondering if it was the effect of one of the latest security patches from MS

Any help is appreciated



Answer this question

Can't debug threads anymore

  • Vhradice

    Thank you very much for the detailed explanation. I don't know why it had worked for me before, or why I don't have this problem on other PCs.

    Anyway based on your explanation I created the workaround to declare the thread function as static, if the task allows this it helps too.


  • arsonist

    Hi,

    This is a known issue to do with func eval aka property evaluation and WinForms applications. To work around this you can disable Tools -> Options -> Debugging -> General -> Enable property evaluation and other implicit function calls.

    More details on this issue can be found here http://blogs.msdn.com/greggm/archive/2005/11/18/494648.aspx.

    We are looking at this issue and hope to have something for future releases.

    Azeem Khan

    Visual Studio Debugger.


  • Keith Chapman

    the rest of the project is the unaltered default code you get when creating a new project in VS
    by the way I can't debug other threads too, so the code provided is just a simple example to show that nothing complicated is needed to reproduce the behaviour

    The forms window is visible during debugging


  • Fillipe246466

    That sounds weird - sorry, no idea other than reinstalling VS comes to my mind.

    --
    SvenC


  • bilalso

    Hi,

    what is the code of your Main function Does it show the form Is the form still visible when you debug the other thread

    --
    SvenC


  • Can't debug threads anymore