How to catch null reference exception to create a dump?
<p>Application is not getting crashed while trying for null reference exception. Code is as below.</p>

<pre><code>string a = null;   // These two lines are in another method.
int i = a.Length; // These two lines are used to raise null reference exception.
</code></pre>

<p>In main()</p>

<pre><code>AppDomain currentDomain = AppDomain.CurrentDomain;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
currentDomain.UnhandledException += AppDomain_UnhandledException;
Application.ThreadException += Application_ThreadException;
</code></pre>

<p>AppDomain_UnhandledException is never reached. and Application_ThreadException is also never reached. Is there any other option to catch this.</p>
