Building C# bindings for ADLX

This guide outlines the steps to build a C# binding wrapper for ADLX, a prerequisite to programming with ADLX in a C# application.

Prerequisite(s)

  • ADLX SDK is installed.

  • Visual Studio 2019 is installed.

  • swigwin 4.0.2 is installed, and the path to the swigwin 4.0.2 installation is added to the Path user environment variable.

To build ADLX bindings in C#

  1. Create and name a folder for the C# ADLX binding wrapper, for example ADLXCSharpBind.

  2. Create a new file in the ADLXCSharpBind folder and title it ADLXCSharpBind.i.

  3. Edit ADLXCSharpBind.i and add the SDK header files for the interfaces you wish to wrap by using the SWIG input format. To create bindings for event notifications, turn on the director wrapping callback for respective listener interfaces.

    For example,

    Copied!

    feature("director") IADLXDisplayListChangedListener;

    Note: Refer to the C# samples ADLXCSharpBind.i file for an example of a C# binding.

  4. Create a C++ Dynamic Link Library project named ADLXCSharpBind and configure the project as follows:

    • Key

      Value

      Observations

      C/C++ > Precompiled Header

      Not Using Precompiled Headers

      Do not use precompiled headers

  5. Add the ADLXCSharpBind.i file to the project.

  6. Right-click the ADLXCSharpBind.i file, and select Properties from the menu. In the Properties dialog select Configuration Properties> General> Item Type> Custom Build Tool.

    Set the configuration as follows:

    • Key

      Value

      Observations

      Command Line

      if not exist $(SolutionDir)out mkdir $(SolutionDir)out swig.exe -c++ -csharp -dllimport ADLXCSharpBind -outdir ../out/ ADLXCSharpBind.i

      Invoke SWIG.exe to build ADLXCSharpBind.i file

      Outputs

      %(Filename)_wrap.cxx

      Set output file name format

  7. Build the project.

    Result: The following files are added to the ADLXCSharpBind project output folder:

    • ADLXCSharpBind_wrap.h file.

    • ADLXCSharpBind_wrap.cxx file.

    • All *.cs files that correspond to the additional interfaces in the ADLXCSharpBind.i file.

  8. Add the following files to the project:

    • ADLXCSharpBind_wrap.h

    • ADLXCSharpBind_wrap.cxx

    • SDK/Platform/Windows/WinAPIs.cpp

    • SDK/ADLXHelper/Windows/Cpp/ADLXHelper.h

    • SDK/ADLXHelper/Windows/Cpp/ADLXHelper.cpp

  9. Rebuild the project.

    Result: The ADLXCSharpBind.dll is built in the "$(SolutionDir)$(Platform)$/(Configuration)/" folder.