Skip to content

Hello World Sample

Gregg Miskelly edited this page Jan 26, 2019 · 3 revisions

To demonstrate the basic parts of a Concord component, this SDK starts with the same sample that every new platform starts with – hello world. In the case of Concord, this means adding an annotated ‘Hello World’ frame to the call stack:

Hello World in Call Stack window

Browsing the Hello World project

This repo includes two different HelloWorld samples – one written in native code (native C++), and one written in managed code (C#). They both are found in the ‘HelloWorld’ folder. The Concord API is nearly identical between managed and native code, and any extension may be written in either managed or native code. So open up whichever sample you are most likely to develop your extension in. The samples include a VSIX project for deploying the sample into an experimental Visual Studio instance. This requires the Visual Studio SDK. If you've already installed Visual Studio without the SDK, you can install it using Add/Remove Programs, select Visual Studio, click Modify, then make sure 'Visual Studio Extensibility Tools' is checked. If you would like to open the project without installing the SDK, open the project file from the ‘.dll’ folder instead.

Let’s look at some of the more interesting files in the sample:

File Description
_HelloWorldService.cpp/.h/.cs The one and only public (exported) class in the sample. In Concord, classes implement interfaces, and Concord calls into these classes through the implemented interfaces. The sample implements the IDkmCallStackFilter interface on this class. In native code, Concord uses COM activation (DllGetClassObject) to obtain this object. So this class includes the ATL glue for hooking up to DllGetClassObject. Note: while Concord uses the standard DllGetClassObject approach, it is not calling CoCreateInstance, so unlike standard COM, in Concord your CLSID does not need to be registered. In managed code, this class is created through reflection. So the class is simply marked as public, and has a default public constructor
HelloWorldDataItem.cpp/.h/.cs FilterNextFrame is called once for each frame in the call stack. However it needs to know which frame is the first frame so that it can be sure to add the ‘[Hello World]’ frame exactly once for each call stack. To do so, the sample needs to associate a bit of data with each call stack. This data item class is the mechanism that Concord uses to associate information with a Concord object. Most of the important Concord objects (including DkmStackContext in this sample) derive from DkmDataContainer. DkmDataContainer allows any Concord component to store its own private information in a Concord object. In the sample, this data item class uses a ‘State’ enum to keep track of if the ‘[Hello World]’ frame has been added yet
HelloWorld.vsdconfigxml HelloWorld.vsdconfigxml is an XML file which describes the hello world component – what classes does it have, which interfaces does each class implement, when should these interfaces be called. The sample’s build process runs a custom tool over this file (vsdconfigtool.exe) which validates this file, and turns it into a binary file (HelloWorld.vsdconfig) which is deployed alongside HelloWorld.dll. The Concord component loading system then loads all these .vsdconfig files on startup so that it can route requests to each registered component.
[C++ sample only] packages.config, packages.version.props This project obtains Concord headers, libs and build tools from nuget.org. These two files indicate the version to obtain. Note that the C# sample also uses nuget packages, but it does so using PackageReference items in the .csproj file.

Running the Sample in Visual Studio

To run the sample in Visual Studio, open HelloWorld.sln from HelloWorld/Cs or HelloWorld/Cpp. Then do the following:

  1. Right click on the ‘vsix’ project and use ‘Set As StartUp Project’.
  2. Hit F5 to launch an experimental instance of Visual Studio under the debugger.
  3. In the Experimental Instance:
  4. Open or create a C++ or C# project
  5. F10
  6. When the project finishes launching, open the Call stack window and notice that there is now a ‘Hello World’ frame on top.
Clone this wiki locally