Tracing HowTo?

Topics: CAB & Smart Client Software Factory
Dec 15, 2005 at 6:56 AM
originally posted by: UncleFestis

Anyone got any tips on how to get tracing working with CAB?
Dec 15, 2005 at 9:37 AM
originally posted by: BradWilsonMSFT

CAB uses the System.Diagnostics tracing system internally, so enabling CAB's tracing means enabling the trace sources that you want to listen to.

For example, if you want to listen to the EventBroker tracing, edit your App.config and add these lines:

<configuration>
<system.diagnostics>
<switches>
<add name="Microsoft.Practices.CompositeUI.EventBroker.EventTopic" value="All" />
</switches>
</system.diagnostics>
</configuration>

You can find the classes that have event information, because they will have TraceSource objects decorated with the ClassNameTraceSource attribute, which creates a trace source whose name is the name of the containing class. You can search the CAB source code for ClassNameTraceSource to find them all.

In addition, there is a trace source for ObjectBuilder which uses a different pattern (obviously, ObjectBuilder can't use dependency injection, since it's the dependency injection system :). The source name for ObjectBuilder is "Microsoft.Practices.ObjectBuilder", which you can see being created in CabApplication<T>.CreateBuilder().