<p>The following bit of code catches the EOS Exception</p>

<pre><code>using (var reader = new BinaryReader(httpRequestBodyStream)) {

    try {
        while (true) {
            bodyByteList.Add(reader.ReadByte());
        }
    } catch (EndOfStreamException) { }
}
</code></pre>

<p>So why do I still receive first-chance exceptions in my console? </p>

<blockquote>
  <p>A first chance exception of type 'System.IO.EndOfStreamException' occurred in mscorlib.dll</p>
</blockquote>

<p>Is there a way to hide these first chance exception messages?</p>

[{'answer_id': 58381, 'author': 'DevelopingChris', 'author_id': 1220, 'author_profile': 'https://Stackoverflow.com/users/1220', 'pm_score': -1, 'selected': False, 'text': "<p>I think the stream is throwing this exception, so your try is scoped to narrow to catch it.</p>\n\n<p>Add a few more try catch combos around the different scopes until you catch it where its actually being thrown, but it appears to be happening either at our outside of your using, since the stream object is not created in the using's scope.</p>\n"}, {'answer_id': 58387, 'author': 'Brad Wilson', 'author_id': 1554, 'author_profile': 'https://Stackoverflow.com/users/1554', 'pm_score': 7, 'selected': True, 'text': '<p>The point of "first-chance" exceptions is that you\'re seeing them pre-handler so that you can stop on them during debugging at the point of throwing. A "second-chance" exception is one that has no appropriate handler. Sometimes you want to catch "first-chance" exceptions because it\'s important to see what\'s happening when it\'s being thrown, even if someone is catching it.</p>\n\n<p>There\'s nothing to be concerned with. This is normal behavior.</p>\n'}, {'answer_id': 58392, 'author': 'Alex Duggleby', 'author_id': 5790, 'author_profile': 'https://Stackoverflow.com/users/5790', 'pm_score': 4, 'selected': False, 'text': "<ol>\n<li><p>In Visual Studio you can change the settings for the way the Debugger handles (breaks on) exceptions.</p>\n<p>Go to Debug &gt; Exceptions. (Note this may not be in your menu depending on your Visual Studio Environment setting. If not just add it to your menu using the Customize menu.)</p>\n<p>There you are presented with a dialog of exceptions and when to break on them.</p>\n<p>In the line &quot;Common Language Runtime Exceptions&quot; you can deselect thrown (which should then stop bothering you about first-chance exceptions) and you can also deselect User-unhandeled (which I would not recommend) if want to.</p>\n</li>\n<li><p>The message you are getting should not be in the console, but should be appearing in the 'Output' window of Visual Studio. If the latter is the case, then I have not found a possibility to remove that, but it doesn't appear if you run the app without Visual Studio.</p>\n</li>\n</ol>\n"}, {'answer_id': 58409, 'author': 'loudej', 'author_id': 6056, 'author_profile': 'https://Stackoverflow.com/users/6056', 'pm_score': 4, 'selected': False, 'text': '<p>Unlike Java, .NET exceptions are fairly expensive in terms of processing power, and handled exceptions should be avoided in the normal and successful execution path.</p>\n\n<p>Not only will you avoid clutter in the console window, but your performance will improve, and it will make performance counters like .NET CLR Exceptions more meaningful.</p>\n\n<p>In this example you would use</p>\n\n<pre><code>while (reader.PeekChar() != -1)\n{\n    bodyByteList.Add(reader.ReadByte());\n}\n</code></pre>\n'}, {'answer_id': 60765, 'author': 'André Chalella', 'author_id': 4850, 'author_profile': 'https://Stackoverflow.com/users/4850', 'pm_score': 8, 'selected': False, 'text': '<p>To avoid seeing the messages, right-click on the output window and uncheck "Exception Messages".</p>\n\n<p>However, seeing them happen might be nice, if you\'re interested in knowing when exceptions are thrown without setting breakpoints and reconfiguring the debugger.</p>\n'}, {'answer_id': 1247084, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': -1, 'selected': False, 'text': '<p>in VB.NET:</p>\n\n<pre><code>&lt;DebuggerHidden()&gt; _\nPublic Function Write(ByVal Text As String) As Boolean\n   ...\n</code></pre>\n'}, {'answer_id': 2799329, 'author': 'AareP', 'author_id': 11741, 'author_profile': 'https://Stackoverflow.com/users/11741', 'pm_score': 2, 'selected': False, 'text': "<p>Actually if are having many exceptions per second, you would achieve must better performance by checking reader.EndOfStream-value.. Printing out those exception messages is unbelievably slow, and hiding them in visual studio won't speed up anything.</p>\n"}, {'answer_id': 13086139, 'author': 'Hallgeir Engen', 'author_id': 813606, 'author_profile': 'https://Stackoverflow.com/users/813606', 'pm_score': 3, 'selected': False, 'text': '<p>I had this problem and couldn\'t figure out where the exception was thrown. So my solution was to enable Visual Studio to stop executing on this kind of exception. </p>\n\n<ol>\n<li>Navigate to "Debug/Exceptions"</li>\n<li>Expand the "Common Language Runtime Exceptions" tree.</li>\n<li>Expand the "System" branch.</li>\n<li>Scroll down to where "NullReferenceException" is, and check the\n"throw" checkbox, and uncheck the "user-handled".</li>\n<li>Debug your project.</li>\n</ol>\n'}, {'answer_id': 23159773, 'author': 'VoteCoffee', 'author_id': 848419, 'author_profile': 'https://Stackoverflow.com/users/848419', 'pm_score': 2, 'selected': False, 'text': '<p>If you want more control over these messages, you can add a handler:</p>\n\n<pre><code>Friend Sub AddTheHandler()\nAddHandler AppDomain.CurrentDomain.FirstChanceException, AddressOf FirstChanceExceptionHandler\nEnd Sub\n\n&lt;Conditional("DEBUG")&gt;\nFriend Sub FirstChanceExceptionHandler( source As Object,  e As Runtime.ExceptionServices.FirstChanceExceptionEventArgs)\n\' Process first chance exception\n\nEnd Sub\n</code></pre>\n\n<p>This allows you to silence them as mentioned in other comments, but still makes sure you are able to be aware of them.  I find it is good to see how many I am really throwing if I log a message and timestamp to a text file.</p>\n'}]
['https://Stackoverflow.com/questions/58380', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/209/']