1

I have inherited a massive C# application, server (a windows service) and client (windows desktop application).

It's deployed at a variety of customer locations.

I have a list of customer issues and bugs to address, but the logging in the application is woefully inadequate.

A couple of times I've taken to adding new lines of logging in the code, rebuilding the code, sending the customer the new DLLs and asking them to install them manually, but this is a very kludgey way to debugging customer problems.

Is there a way to just tell the VM (the dot net runtime engine) to produce a log file of what objects were instantiated, and which methods were entered and exited ... maybe even line numbers of lines of code that were executed?

That sort of thing would help me incredibly.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • You are looking for a profiler. – John Saunders Apr 13 '15 at 21:03
  • What kind of information would you like to collect? There are System.NET tracing for sockets, and WCF tracing for WCF. However, no general tracing is available. – Lex Li Apr 14 '15 at 01:45
  • @LexLi I'm loooking for stuff like ObjectName.Method name entered/exited, maybe code line # executed, that sort of thing. –  Apr 14 '15 at 13:50

1 Answers1

2

No that's not possible to just tell the VM to log things like that. You can however trace everything in your program(method calls etc).

You can use PostSharp to log detailed info on method calls(you don't need this, but this would provide you an automated way to do it in a large project).

There are also some nice alternatives to PostSharp, such as Loom.net and PostCrap.

Your next option is to modify the exe after it's been created to do this type of logging(tracing) by modifying the IL

There is also something like Runtime Flow, but this probably won't fit your requirements due to an unwieldy install.

Kelly Elton
  • 4,373
  • 10
  • 53
  • 97
  • Thanks, Runtime Flow might work for me. Edit: SCRATCH THAT, Runtime Flow requires Visual Studio to be installed on the machine running the application, won't work. –  Apr 14 '15 at 13:52
  • Yeah that's why I was saying it probably won't fit your requirements. I mostly just posted it for the sake of completeness. – Kelly Elton Apr 15 '15 at 15:51
  • Runtime Flow Portable can log method calls without Visual Studio installed. – Sergey Vlasov Mar 26 '17 at 05:25