Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio stops debugging with no errors unexpectedly

I am debugging a project and Visual Studio stops debugging and closes the program on the following line with no exceptions or error messages (I have enabled notifications for any thrown exceptions in options):

var query = Session.Linq<RSS>()
            .Where(x => x.LastRetrieved <= date || x.LastRetrieved == null)
            .Where(x => x.Moderated);

Where Session.Linq refers to LINQ2NHibernate. Anyway, the question is: what are the possible reasons for such behavior? Tested both on VS 2010 and 2008 - they behave identically just falling out of debugging.

Update. If I change application type to "Console Application" it behaves normally. Very strange.

like image 950
Egor Pavlikhin Avatar asked May 02 '10 11:05

Egor Pavlikhin


People also ask

How do I keep debugging in Visual Studio?

In most languages supported by Visual Studio, you can edit your code in the middle of a debugging session and continue debugging. To use this feature, click into your code with your cursor while paused in the debugger, make edits, and press F5, F10, or F11 to continue debugging.

How do I fix the Debug executable in Visual Studio?

Just use File/Open Project/Solution, select EXE file and Open it. Then select Debug/Start debugging. The other option is to run the EXE first and then Select Debug/Attach to process.

How do I enable F10 for debugging in Visual Studio?

Welcome to Microsoft Q&A! Please open CMD and go to C:\Program Files (x86)\Microsoft Visual Studio\2019\version name\Common7\IDE folder, run the command: devenv /safemode to run your Visual Studio in safe mode. Then, create a new project and check if the situation disappears or not.

What is IntelliTrace in Visual Studio?

IntelliTrace always records events that happen in the Visual Studio debugger. For example, starting your application is a debugger event. Other debugger events are stopping events, which cause your application to break execution.


1 Answers

I had a similar problem and although this might not be a solution for your case above, I hope it will help someone else out there.

I had to reference a class that was written by someone else that looked like this:

    public class ItemPrice
    {
        public bool sucessIndicator
        {
            get { return sucessIndicator; }
            set { sucessIndicator = value; }
        }

        public string productCode
        {
            get { return productCode; }
            set { productCode = value; }
        }

        public string description
        {
            get { return description; }
            set { description = value; }
        }

        public double price
        {
            get { return price; }
            set { price = value; }
        }
    }

At first glance it looks ok right... until you notice that each property is referencing it self and not a private member.

So:

public string description
        {
            get { return description; }
            set { description = value; }
        }

is referencing it self recursively and causes a stack overflow exception that did not get shown to me in VS even though I had all exceptions enabled. It just stopped debugging with no warning.

The solution was of course to change it more like this:

public string description
        {
            get;
            set;
        }

Hope that helps someone.

like image 172
Ghlouw Avatar answered Oct 21 '22 17:10

Ghlouw