document.write('<div class="vbnet" style="font-family: monospace;"><br />');
document.write('&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">\'Returns a string representing a full stack for a passed in exception and all inner exceptions</span><br />');
document.write('&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">\'will only get the first 50 inner exceptions to prevent stack overflow</span><br />');
document.write('&nbsp; &nbsp; <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> fullStackTrace<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> ex <span style="color: #FF8000;">As</span> Exception<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">If</span> ex <span style="color: #FF8000;">Is</span> <span style="color: #FF8000;">Nothing</span> <span style="color: #FF8000;">Then</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF8000;">Throw</span> <span style="color: #FF8000;">New</span> ArgumentException<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;ex can not be null&quot;</span>, <span style="color: #808080;">&quot;ex&quot;</span><span style="color: #000000;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> outputStack <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> System.<span style="color: #0000FF;">Text</span>.<span style="color: #0000FF;">StringBuilder</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; outputStack.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span>ex.<span style="color: #0000FF;">StackTrace</span><span style="color: #000000;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> innerReferences <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Byte</span> = <span style="color: #FF0000;">0</span> <span style="color: #008080; font-style: italic;">\'used to ensure memory does not run out</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">\'during stack looping</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> innerException <span style="color: #FF8000;">As</span> Exception = ex.<span style="color: #0000FF;">InnerException</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">While</span> <span style="color: #804040;">Not</span> innerException <span style="color: #FF8000;">Is</span> <span style="color: #FF8000;">Nothing</span> _<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AndAlso innerReferences &lt; <span style="color: #FF0000;">50</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputStack.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, innerException.<span style="color: #0000FF;">StackTrace</span><span style="color: #000000;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; innerException = innerException.<span style="color: #0000FF;">InnerException</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; innerReferences += <span style="color: #0600FF;">CByte</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">While</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; Return outputStack.<span style="color: #0000FF;">ToString</span><br />');
document.write('&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span><br />');
document.write('&nbsp;</div>');
document.write('<br />&nbsp;<br /><div style="font-size: 12px">Brought to you by the community at <a href="http://www.bytemycode.com/snippets/snippet/352/1/" target="_blank">byteMyCode</a>.</div>');
