Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Application does not crash in VS BUT CRASH on system running
    text
    copied!<p>I'm developing a simple test tool to verify how many HASH(SHA1) the customer server can elaborate in 1 second.</p> <p>The attached sample use muti-threading to start and stop a timer that counts executed HASH. The HASHes are sequential.</p> <p>The application works well in Visual Studio, but if I run it outside the VS environment it crashes.</p> <p>The problem is on increment() function in "using" section. If I comment it, everything works well! </p> <pre><code> static void increment() { try { using (SHA1 sha = new SHA1CryptoServiceProvider()) { byte[] result; byte[] data = new byte[20]; new Random().NextBytes(data); result = sha.ComputeHash(data); } Interlocked.Increment(ref safeInstanceCount); } catch (Exception ex) { Console.WriteLine(ex.Message); } } </code></pre> <p>The code used to start and stop the time is the following:</p> <pre><code> bool stop; static void Main() { try { TimerQueueTimer qt; qt = new TimerQueueTimer(); TimerQueueTimer.WaitOrTimerDelegate CallbackDelete = new TimerQueueTimer.WaitOrTimerDelegate(QueueTimerCallback); uint dueTime = uint.Parse(textBox1.Text); // string "60000" = 1 min uint period = 0; qt.Create(dueTime, period, CallbackDelete); while (!stop) { // Thread thread = new Thread(new ThreadStart(increment)); // thread.IsBackground = true; // thread.Start(); increment(); } stop = false; } catch (Exception ex) { Console.WriteLine(ex.Message); } } private void QueueTimerCallback(IntPtr pWhat, bool success) { try { stop = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } </code></pre> <p>How can I understand where is the error?</p> <p>=</p> <p>The application crashes without any exception. I try to catch it, without success, it happened after 60 sec. (Maybe QueueTimerCallback is called?) </p> <p>The application does not generate any error trace and it DOES not crash running under Visual Studio! When it crashes it does not generate any stack trace, just a pop-up crash window giving in detail the "StackHash_xxxxx" error</p> <p>Nothing to do! I've try to use Console.Read (it's a Windows app not console) but I cannot see anything. Here is the error shown! <a href="https://picasaweb.google.com/lh/photo/iHsBhRSy-DNTYVo4CpoeA9MTjNZETYmyPJy0liipFm0?feat=directlink" rel="nofollow">https://picasaweb.google.com/lh/photo/iHsBhRSy-DNTYVo4CpoeA9MTjNZETYmyPJy0liipFm0?feat=directlink</a></p>
 

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