Search code examples
c#winformsvisual-studio-2013visual-studio-debugging

Windows Forms app with AutoWaitCursor - crashing in VS2013CE debugger if platform is x64 or ANY CPU


I have created a a minimal Windows Forms project that I added AutoWaitCursor to demonstrate the problem at https://github.com/rluiten/WinForm-AutoWaitCursor-Problem

Please note AutoWaitCursor is no longer available at the original link I got it from which was http://www.vbusers.com/codecsharp/codeget.asp?ThreadID=58&PostID=1&NumReplies=0

If I launch this Windows Forms Project inside Visual Studio with the Debugger and platform at "Any CPU" or "x64" on my 64 bit Windows 7 PC I get a "vshost.exe has stopped working" dialog appear and the application has crashed.

Launching with Debugger and with platform set to "x86" is not a problem. Launching without the Debugger is not a problem for any platform. Launching resultant compiled binary outside Visual Studio has not yet exhibited a related problem.

It appears to be a coupling of AutoWaitCursor and Visual Studio 2013 Debugger and 64bit mode. I believe currently that VS2012 which I have used in the past did not exhibit this behaviour but I cannot verify that at the moment. While this problem is not a show stopper.

I would like to understand or fix the issue but have not made any progress in that direction yet.


Solution

  • In the signature for SendMessageTimeout, change the int and string(!) parameters to IntPtr.

    In _IsApplicationBusy, change result to be IntPtr; use IntPtr for the parameters you changed in the API signature; last line should be return result != IntPtr.Zero;

    Test everything is working by using your github app, dropping a button onto the form and running Thread.Sleep(3000); in a Click handler.