0

This is Windows Forms application.

As in title, I can't debug Task in Visual Studio 2015. If I will check breakpoint at line var a = costam(); it will be hit, but if then I will press step into, or continue, execution will not be continued. This works fine in Console Application. For now i checked, that error appears when I'am trying to run my own method in Task, or if I'am invoking something.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        Task.Run(() =>
        {
            var a = costam();
        });
    }

    string costam()
    {
        return "s";
    }
}
titol
  • 999
  • 13
  • 25
  • Perhaps this post helps? [Tracking Crash in Winform](http://stackoverflow.com/questions/32978692/tracking-crash-in-winform/32979730#32979730) – David J. Dec 01 '15 at 10:39
  • In VS2013 everything works fine. Update 1 to VS2015 seems to solve this issue. – titol Dec 01 '15 at 12:56

2 Answers2

0

I would suggest changing the settings to break on any exception in the debug menu, not only uncaught ones. This option is called breaking when the exception is "thrown". Unfortunately the 2015 exceptions menu I'm not familiar with so I can't help you out with that.

There are certain exceptions that are caught and suppressed behind the scenes, especially with WinForms--constructors / load events are particularly shielded. It's likely that it doesn't like spawning a new thread in the UI thread which is why it's throwing an exception in your WinForms application but not the console application. This also explains why "stepping in" "doesn't work"--it steps in but the exception means the next breakpoint isn't hit.

j.i.h.
  • 815
  • 8
  • 29
  • Hmm.. I dont think this is issue. The same code is working in VS2013. There is no exception in this code. Breakpoint that I set is hit, but you can't resume application. It looks like it is resumed in Visual Studio, but application does not working. – titol Nov 30 '15 at 19:56
  • Just try to enable breaking on all exceptions and seeing if an exception is being hit behind the scenes. Also try putting the exact same code in a click event and seeing what happens. – j.i.h. Nov 30 '15 at 20:00
  • I was trying this earlier. Click event - everything is the same – titol Nov 30 '15 at 20:44
0

Update 1 to VS2015 seems to solve this issue.

titol
  • 999
  • 13
  • 25