You don't have to run TraceSrv as a service to allow access to it across a network—TraceSrv works just as well running as a COM+ remote server. This flexibility is convenient for debugging because all you need to do is start TraceSrv in the debugger and you can watch clients connect to it and debug when appropriate. What worked best for me was to run both the client and TraceSrv under debuggers on their respective machines; when either application hit a breakpoint, I would break on the other to avoid any possible timeout problems. I always compiled the Visual Basic client down to native code and ran it under the Visual C++ debugger. This tactic ensured that when the client hit a breakpoint, it was stopped dead in the debugger. The reason you can't stop the client under the Visual Basic debugger is that the client that connects to TraceSvr is actually the Visual Basic debugger, not the application being debugged.
When you want to use TraceSrv across a network, you need to run the DCOMCNFG.EXE program to get the proper information set in the registry. The first thing you need to do is to get the default COM+ properties set up for your machine. Because you could leave your machine exposed to some serious security problems, you might want to check with your network administrators before changing the default COM+ properties in a company environment. If you have a small network and are King of the Domain, as I am, you can use the settings listed in Table 11-1. These are the settings that worked best for me on all the machines I tested TraceSrv on.
Table 11-1 DCOMCNFG Default Settings
On the Default Properties Tab in DCOMCNFG | ||
---|---|---|
Enable Distributed COM On This Computer | Checked | |
Default Authentication Level | Connect | |
Default Impersonation Level | Identify | |
On the Default Security Tab in DCOMCNFG.EXE | ||
Default Access Permissions | Everyone | Allow Access |
INTERACTIVE | Allow Access | |
NETWORK | Allow Access | |
SYSTEM | Allow Access | |
Default Launch Permissions | Administrators | Allow Launch |
Everyone | Allow Launch | |
INTERACTIVE | Allow Launch | |
NETWORK | Allow Launch | |
SYSTEM | Allow Launch | |
Default Configuration Permissions | Administrators | Full Control |
CREATOR OWNER | Full Control | |
Everyone | Read | |
INTERACTIVE | Special Access (Check all except Create Link, Write DAC, and Write Owner) | |
SYSTEM | Full Control |
After you've registered TraceSrv (either as part of the build or with the -RegServer command-line switch), start DCOMCNFG, select TraceSrv (or Trace Class on Windows 98), and click the Properties button. I changed settings only on the Location tab. If you want to run TraceSrv only on the local machine, check Run Application On This Computer and leave the other options unchecked. If you want to run TraceSrv only on another machine, check Run Application On The Following Computer, and specify the server. (Note that DCOMCNFG will let you put the current computer name in the box, but then it won't create the server.) To avoid lots of headaches, double-check that all the options on the Security tab are set to use the defaults.
For the most part, you shouldn't have to change the settings in DCOMCNFG. For fun, try setting different security and identity options to see what effect they have on starting and connecting to TraceSrv. If you get into a situation in which you can no longer start TraceSrv, simply run TraceSrv with the -UnRegServer command-line switch—the registry will be cleaned out so that you can start fresh again. Automatic registration and unregistration are handy features of ATL.
Now that you know how I designed, built, and set up TraceSrv, you probably think you've reached the end of this chapter. Originally, I thought so too, but then some really nasty bugs showed up when I started using TraceSrv.