How to take a System.Net trace from Windows Store applications (Developer Preview)

In desktop applications and services we frequently take System.Net traces to diagnose issues using the HttpWebRequest class, HttpListener, sockets, smpt etc… (and now the HttpClient classes).  We traditionally use the application configuration file (appname.exe.config) to enable the tracing.  The config file is read and the tracing parameters are used to trace the information we find useful.   Windows Store applications do not have configuration files however so you cannot use the application configuration file to take the trace.

The good news is that you can go further up and put your tracing settings in the machine.config file!  The one minor issue is that any process using will be included in the trace file if it starts after you make the change.  If you use my trace file it logs the process and time so you can use that to filter the trace information see: My Favorite System.Net trace configuration file dumps Process ID and Date Time Information .

Here are the steps:

You will be making changes to the machine.config file. If you mess this up, you could keep .NET framework applications from running so be SURE you make a copy of the file that you can restore after you have gotten your trace! If you are using a 64 bit build you make the config changes in the Framework64 tree.

    • Save a copy of C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config because you will be modifying this file (or C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config if your image is a 64 bit build)
    • Open Notepad as an Administrator (right mouse click or press and hold with touch and choose ‘Run as Administrator’
    • From your Administrator Notepad open: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config (or C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config if your image is a 64 bit build)
    • Add the normal System.Net tracing setup at the bottom of the file before the </configuration> tag (see above link)
    • Find this section in the text you just added to machine.config:
      traceOutputOptions = "ProcessId, DateTime"
    • Change the path and file name of initializeData to “c:\temp\network.log” (or a path of your choosing)
      traceOutputOptions = "ProcessId, DateTime"
    • Save the file
    • Create the directory c:\temp\ (or if you chose a different directory go to that), and give the local user named “ALL APPLICATION PACKAGES” full control of the directory.  To do this:

a. Right click on the c:\temp folder and select properties
b. Click on the security tab
c. Hit the Edit button
d. Hit the Add button
e. Hit the Locations... button and change the location to the very top item (the name of your computer)
f. In the space below Enter the object names to select add ALL APPLICATION PACKAGES and hit Check Names
g. Hit OK and check Allow, Full control for the ALL APPLICATION PACKAGES and then hit OK again to apply your changes

  1. Start your application and recreate the issue you wish to trace, and close your application
  2. Restore the machine.config file from the copy you created in step 1

You can then analyze the trace as you would in the past!

Please let me know if you have found this useful or have any questions.