Search code examples
c#visual-studiovisual-studio-2015intellitrace

Adding custom IntelliTrace diagnostics events with ProgrammableDataQuery


I have created a couple of Custom DiagnosticEventSpecification for IntelliTrace. This works as expected.

 <DiagnosticEventSpecification enabled="true">
    <Bindings>
      <Binding onReturn="false">
        <ModuleSpecificationId>DiagnosticsTester</ModuleSpecificationId>
        <TypeName>DiagnosticsTester.IntellitraceTest</TypeName>
        <MethodName>TestTrace2</MethodName>
        <MethodId>DiagnosticsTester.IntellitraceTest.TestTrace2(System.String):System.Void</MethodId>
        <ShortDescription _locID="IntelliTraceEnterEvent_ShortDescription">The method TestTrace2.1 was called</ShortDescription>
        <LongDescription _locID="IntelliTraceEvent_LongDescription">View the Locals window for details about the collected data</LongDescription>
        <AutomaticDataQuery level="All" />
      </Binding>
      <Binding onReturn="true">
        <ModuleSpecificationId>DiagnosticsTester</ModuleSpecificationId>
        <TypeName>DiagnosticsTester.IntellitraceTest</TypeName>
        <MethodName>TestTrace2</MethodName>
        <MethodId>DiagnosticsTester.IntellitraceTest.TestTrace2(System.String):System.Void</MethodId>
        <ShortDescription _locID="IntelliTraceExitEvent_ShortDescription">The method TestTrace2.1 returned</ShortDescription>
        <LongDescription _locID="IntelliTraceEvent_LongDescription">View the Locals window for details about the collected data</LongDescription>
        <AutomaticDataQuery level="All" />
      </Binding>
    </Bindings>
    <CategoryId>IntelliTrace.generated.8889ce9d-2320-40c0-a6bf-dfac215354d2</CategoryId>
    <SettingsName _locID="">DiagnosticsTester.IntellitraceTest.TestTrace2</SettingsName>
    <SettingsDescription _locID=""></SettingsDescription>
  </DiagnosticEventSpecification>

When i try to use the ProgrammableDataQuery it fails to capture the event. According to ProssesMon and "Fusion log viewer" Intellitrace never tries to load my custom dll. The definition look like this:

   <DiagnosticEventSpecification enabled="true">
    <Bindings>
      <Binding>
        <ModuleSpecificationId>DiagnosticsTester</ModuleSpecificationId>
        <TypeName>DiagnosticsTester.IntellitraceTest</TypeName>
        <MethodName>TestTrace2</MethodName>
        <MethodId>DiagnosticsTester.IntellitraceTest.TestTrace2(System.String):System.Void</MethodId>
        <ProgrammableDataQuery>
          <ModuleName>UnikDataQuery.dll</ModuleName>
          <TypeName>UnikDataQuery.TestDataQuery</TypeName>
        </ProgrammableDataQuery>
      </Binding>
    </Bindings>
    <CategoryId>IntelliTrace.generated.8889ce9d-2320-40c0-a6bf-dfac215354d2</CategoryId>
    <SettingsName _locID="">DiagnosticsTester.IntellitraceTest.TestTrace2</SettingsName>
    <SettingsDescription _locID=""></SettingsDescription>
  </DiagnosticEventSpecification>

I have placed the dll besides the IntelliTrace standalone collector and inside the VS2015 folder for IntelliTrace C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\14.0.0


Solution

  • A dll with PDQ should be put in a folder with IntelliTace.exe program. In other words if you use IntelliTrace that is integrated into Visual Studio then UnitQuery.dll should be copied to the folder mentioned by you i.e.:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\14.0.0
    

    By the way, in this folder you can also find Microsoft.VisualStudio.DefaultDataQueries which a dll with default PDQs used by VS.

    However, if you use the standalone collection you must copied your dll to its install directory.

    I did it many times and it worked fine. It is also worth verifying if you dll was compiled with the platform target set to Any CPU. It will allow to avoid compatibility issues.

    My last comment is that your dll with PDQ is not needed only to capture a log but also to:

    • open it in VS
    • analyse it with IntelliTrace API.

    For example, if you:

    • use the standalone collection in order to capture a log
    • you want to open this log in Visual Studio

    Then UnitQuery.dll must be copied to both locations.