views:

62

answers:

4

I am creating an GUI using winforms in C#, all the controls have numerous events. I would like to know which of these events are being fired and when. One way would be to put debug statements on each of the event handlers but that would require too much work. Is there any way of doing this in Visual Studio 2008/2010 or are there any tools that can help?

A: 

You could write a logging class that subscribes to these events and write the event plus the time stamp into a log file.

It still requires that you write some code, but it's independent of your production code and shouldn't affect it any way.

ChrisF
is it possible to subscribe to every single event all in one go or individually? Not so bothered about logging them as I am more interested in finding out which events are fired and when so that I can use or handle them if required.
Piers Myers
@Piers - you'll have to subscribe to them individually I'm afraid. I wasn't sure exactly what you wanted to do - hence the logging suggestion.
ChrisF
A: 

If you don't mind some information overload, you could use Spy++ (\Common7\Tools\Spyxx.exe) to see all the windows messages generated by the application.

Some of the window messages translates more or less directly to .net events...

Per-Frode Pedersen
+2  A: 

Managed Spy has possibility to log all events of chosen control. See this article where you can read about this tool and download it.

Genrih
This looks good, however having problems compiling and running it on Vista 64 with VS 2010. Getting error: `Could not load file or assembly 'ManagedSpyLib, Version=1.0.3877.33621, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.`
Piers Myers
I believe this is really problem with 64bit system. The injection of Managed Spy code into your program should be different on such system. Unfortunately I don't know whether there is some 64bit version, all i can advise it to try 32bit, e.g. on virtual machine
Genrih
I am marking this as the correct answer as it looks like exactly what I need even though I couldn't get it to work.
Piers Myers
+1  A: 

Runtime Flow with the monitoring filter "Module == System.Windows.Forms.dll && Function == On*" will show what events are firing for all winforms controls.

Sergey Vlasov
Looks like a good app, however you should read the stackoverflow FAQ:"May I promote products I am affiliated with here?Be careful, because the community frowns on overt self-promotion and tends to vote it down and flag it as spam. Post good, relevant answers, and if they happen to be about your product, so be it. However, you must disclose your affiliation with the product in your answers. Also, if a huge percentage of your posts include a mention of your product, you're clearly here for the wrong reasons. Our advertising rates are quite reasonable;"
Piers Myers