4

I am writing an ETW consumer to listen for ASP.NET events. I have the sample code below working nicely on a Windows 2008 server where it can see the ASP.NET provider. The problem that I am running into is that on my Win7 (64) PC, I do not see the ASP.NET provider so this code shows all the events as “unhandled”. I have made sure the tracing feature is installed and the applicationhost.config file has the respective values in it.

When I do a logman –query providers, I do not see the ASP.NET AFF081FE-0247-4275-9C4E-021F3DC1DA35 provider on the PC, but I see this on the Win2008 server that I am testing on.

How can I do one of the two items below: Add this as a provider to my Win7 PC?

OR

Have the code able to handle this message and provide the manifest in my code. When I set “AFF081FE-0247-4275-9C4E-021F3DC1DA35” as a provider, I do get events but they are from unknown provider. So I am guessing the manifest content is missing.

My sample code is below

    static void Test3()
    {
        var sessionName = "ASPNETMonitorSession";
        using (var session = new TraceEventSession(sessionName, null))  
        {
            Console.WriteLine("Starting Test1");
            session.StopOnDispose = true;
            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
            {
                session.Dispose();
            };
            using (var source = new ETWTraceEventSource(sessionName, TraceEventSourceType.Session))
            {
                Action<TraceEvent> action = delegate(TraceEvent data)
                {
                    Console.WriteLine("GOT EVENT: " + data.ToString());
                };

                var registeredParser = new RegisteredTraceEventParser(source);
                registeredParser.All += action;
                source.UnhandledEvents += delegate(TraceEvent data)
                {
                    if ((int)data.ID != 0xFFFE)         
                        Console.WriteLine("GOT UNHANDLED EVENT: " + data.Dump());
                };

                session.EnableProvider(new Guid("AFF081FE-0247-4275-9C4E-021F3DC1DA35"));
                Console.WriteLine("Starting Listening for events");
                source.Process();                                                              
            }
        }
        Console.WriteLine("Done");
        return;
    }
Scott Manning
  • 163
  • 3
  • 10

1 Answers1

0

The reason why ASP.NET tracing isn't available in your local machine is because it is not installed. If you look at the perfview help it gives you instructions as to how to enable it.

FYI perfview uses TracEevent to capture traces.

Here it is

ASP.NET Events
ASP.NET has a set of events that are sent when each request is process. PerfView has a special view that you can open when ASP.NET events are turned on. By default PerfView turns on ASP.NET events, however, you must also have selected the 'Tracing' option when ASP.NET was installed for these events to work. Thus if you are not seeing ASP.NET events you are running an ASP.NET scenario this is one likely reason why you are not getting data.

To turn on ASP.NET Tracing

The easiest way to turn on tracing is with the DISM tool that comes with the operating system. Run the following command from an elevated command prompt

DISM /online /Enable-Feature /FeatureName:IIS-HttpTracing

Note that this command will restart the web service (so that it takes effect), which may cause complications if you ASP.NET service handles long (many second) requests. This will either force DISM to delay (for a reboot) or abort the outstanding requests. Thus you may wish to schedule this with other server maintenance. Once this configuration is done on a particular machine, it persists. You can also do this configuration by hand using a GUI interface. You first need to get to the dialog for configuring windows software. This differs depending on whether you are on a Client or Server version of the operating system.

On Client - Start -> Control Panel -> Programs -> Programs and Features -> Turn Windows features on or off -> Internet Information Services -> World Wide Web Services -> Health and Diagnostics -> Tracing On Server - Start -> Computer -> Right Click -> Manage Roles -> Web Server (IIS) -> Roll Services Add Role Services Health and Diagnostics -> Tracing

Hope this helps.

Naveen
  • 4,092
  • 29
  • 31