Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:20:17+00:00 2026-06-04T17:20:17+00:00

Normally, when the debugger is attached, Visual Studio 2010 stops at an unhandled exception

  • 0

Normally, when the debugger is attached, Visual Studio 2010 stops at an unhandled exception even if the Exceptions dialog doesn’t have the tickmark for the exception type in the “Thrown” column. The keyword here is unhandled; said dialog refers only to handled exceptions.

However, in the following minimal example, Visual Studio 2010 does not stop at the exception for me, even though it appears in the Immediate Window as a first-chance exception:

EDIT: The first minimal example I posted was fixed by the first answer I received, but unfortunately the following example still exhibits the problem:

using System;
using System.Net.Sockets;

namespace SocketTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var listener = new TcpListener(8080);
            listener.Start();
            AsyncCallback accepter = null;
            accepter = ar =>
            {
                var socket = listener.EndAcceptSocket(ar);
                var buffer = new byte[65536];
                AsyncCallback receiver = null;
                receiver = ar2 =>
                {
                    var bytesRead = socket.EndReceive(ar2);
                    throw new InvalidOperationException();
                    socket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, receiver, null);
                };
                socket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, receiver, null);
                listener.BeginAcceptSocket(accepter, null);
            };
            listener.BeginAcceptSocket(accepter, null);

            Console.WriteLine("Feel free to connect to port 8080 now.");
            Console.ReadLine();
        }
    }
}

If you run this, connect to it by running telnet localhost 8080 and then type any character into telnet, hopefully you will see what I see: the program just aborts silently.

Why does Visual Studio apparently swallow this exception? Can I get it to break at the exception as it usually does?

(Interestingly, throwing inside the BeginAcceptSocket callback does get caught, as does an exception in a normal thread started with Thread.Start. I can only reproduce the issue by throwing inside the BeginReceive callback.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:20:18+00:00Added an answer on June 4, 2026 at 5:20 pm

    This is a known bug in CLR version 4. The feedback article is here. A possible workaround is to change the framework target to version 3.5. I’ll just quote the relevant portion of the feedback response:

    We have investigated the issue and determined there is a bug in CLR
    v4.0 which causes this. The process does throw the exception (you can
    catch it with a catch handler for example) but the debugger was not
    properly notified of the unhandled exception. This causes the process
    to appear to exit without any indication from the debugger about what
    happened. We have investigated potential fixes, however all of the
    fixes had moderate risk of breaking other functionality. Because it
    was very late in product cycle we decided it was safer not to fix this
    issue and risk creating new bugs. We will continue to track this issue
    as part of our next release cycle.

    The issue is restricted to exceptions that escape managed code where
    the thread was created using a few specific API calls:
    new
    System.Threading.Timer()
    ThreadPool.UnsafeQueueNativeOverloapped
    ThreadPool.BindHandle
    ThreadPool.RegisterWaitForSingleObject.

    It is RegisterWaitForSingleObject() in this specific case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Normally in Visual Studio, a watch cannot be evaluated unless the debugger is stopped
Normally I would leave it unhandled and the debugger (gdb, Eclipse CDT) would show
I normally build my solution with MSBuild in order to keep Visual Studio responsive
I'm currently investigating a windows crash dump and the Visual Studio debugger shows me
I am using Visual Studio 2010 to debug an application mostly written in C.
Normally ( Based on my understanding ) i have to follow a lot of
I don't normally go to stackoverflow for sigsegv errors, but I have done all
Edit: Works perfectly in debugger now, but block doesn't rotate at all when run
I have a .js file that normally gets executed by cscript.exe (i.e. is not
If I hit continue, does the code execute normally after the debugger statement? If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.