Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As it turns out, I am <em>not</em> crazy. Based on the answers I got to this question, I think it seemed like I was having difficulty understanding what is so clearly outlined in the spec. It's really not at all difficult to grasp.</p> <p>The truth is that the spec makes sense, while the behavior wasn't. This is seen even more so when you run the code in an older runtime, where it behaves <strong>completely</strong> different...or at least <em>appears</em> to.</p> <h3>A quick recap</h3> <p>What I saw, on my x64 Win7 machine:</p> <ul> <li><p>.NET v2.0-3.5 - WER dialog when the <code>CryptographicException</code> is thrown. After hitting <code>Close the program</code>, the program continues, as if the execption were never thrown. The application is <strong>not terminated</strong>. This is the behavior one would expect from reading the spec, and <a href="http://blogs.msdn.com/b/cbrumme/archive/2003/10/01/51524.aspx" rel="nofollow noreferrer">is well defined by the architects</a> who implemented exception handling in .NET.</p></li> <li><p>.NET v4.0-4.5 - No WER dialog is displayed. Instead, a window appears asking if you want to debug the program. Clicking <code>no</code> causes the program to terminate immediately. No finally blocks are executed after that.</p></li> </ul> <p>As it turns out, pretty much anybody who would try to answer my question would get the exact same results as I did, so that explains why nobody could answer my question of why the runtime was terminating from an exception that it swallowed.</p> <h3>It's never quite what you expect</h3> <p>Who would have suspected the <strong>Just-In-Time debugger</strong>?</p> <p>You may have noticed that running the application under .NET 2 produces a different error dialog than .NET 4. However, if you're like me, you've come to expect that window during the development cycle, and so you didn't think anything of it.</p> <p>The vsjitdebugger executable was forcibly terminating the application, instead of letting it continue. In the 2.0 runtime, <code>dw20.exe</code> doesn't have this behavior, in fact, the first thing you see is that WER message.</p> <p>Thanks to the jit debugger terminating the application, it made it <strong>seem</strong> like it wasn't conforming to what spec says when, in fact, it does.</p> <p>To test this, I disabled the vsjitdebugger from launching on failure, by changing the registry key at <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Auto</code> from 1 to 0. Sure enough, the application ignored the exception and continued on, just like .NET 2.0.</p> <p><img src="https://i.imgur.com/Chcgv.png" alt="Running in .NET 4.0" title="Running in .NET 4.0"></p> <hr> <p>As it turns out, there is a workaround, though there's really no reason to workaround this behavior, since your application is terminating.</p> <ol> <li>When the Just-In-Time debugger window pops up, check <code>Manually choose the debugging engines</code> and click yes, that you want to debug.</li> <li>When Visual Studio gives you engine options, click cancel.</li> <li>This will cause the program to continue, or a WER dialog to pop up, depending on your machine configuration. If that happens, telling it to close the program won't actually close it, it will continue running as if everything was okay.</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload