Question

I have some .net apps running that I need to monitor for example, then MethodA is called in App1, my monitor app should detect this. I have a lot of running apps and the solution proposed here is to recompile all those apps and include a new line in the desired methods that we want to monitor. I want to do this only if there is absolutely no way. So did anybody ever done something like this? Basically, I need to create a new app that when I click a button on it, it will tell me: MethodA was called in App1, in real time...

thanks!

Was it helpful?

Solution

There are several ways you could do this. One is to use log4Net, 'sprinkle' your methods with calls to log4Net's write methods. You can choose a variety of logging appenders (destinations) such as email or a database, but a less known tip is to download the standalone program, DebugView (SysInternals -> now Microsoft) which listens for the default messages.

OTHER TIPS

The PostSharp deliver way, how to edit compiled .net code. The editation is written in C# code which is compiled ( attributes ) or by configuration code. Thay have a mechanism, which can log ( or populate or anything else ) a method/event calling and much more.

I think, this is tool, you need.

System.Diagnostics.PerformanceCounter is a good place to start. You can create new counters that can be viewed in the Performance control panel applet. They're a little confusing at the start, but when you realize average counters need two components to calculate a percentage it gets a lot easier.

I don't know if .NET has a matching mechanism, but Java allows you to specify an agent JAR file, namely a class that is notified/invoked when each class is loaded. Then, via instrumentation/bytecode manipulation, you could intercept such method calls. Perhaps you can replace the class loader in some way in .NET. not sure.

Reflection is what you are looking for in .NET, but I am not sure of the implementation details behind what you want to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top