Canlib Tutorial Overview

Before you start

Here we will go through some things that might be good to know before you start CAN bus programming with Canlib.

Importing Canlib

In order to program using Canlib, you will need to add a reference to the library. To do this in Visual Studio, follow these steps:

  1. Right click on your project in the Solution Explorer and select โ€œAdd referenceโ€. In some versions of Visual Studio, you need to right click the References folder under your project instead.
  2. Right click on your project and select โ€œPropertiesโ€ (Hotkey: Alt+Enter). Then select Build. Under โ€œConfigurationsโ€, select โ€œAll Configurationsโ€ and under โ€œTarget platformโ€ select either โ€œx86โ€ or โ€œx64โ€.
  3. Press โ€œBrowseโ€ and browse to the correct version of the CanlibCLSNET.dll. It will be in the โ€œCanlibdotnetโ€ directory, but which file to use depends on your target platform and .NET version. If youโ€™re building your project for 32 bit processors, select the x86 directory. If youโ€™re building for 64 bit processors, select x64. Next, you need to pick the correct dll for your version of the .NET Framework. If you use a version older than 4.0, select fw11 (x86 only), otherwise select fw40. In this directory, you will find the .dll you need.
  4. You should now be able to write a program by importing the CanlibCSLNET namespace. (using CanlibCSLNET)

CanKing

Kvaser CanKing is a CAN bus monitor which you can use to test your programs. You can find it here.

CanKing can be used for both sending and receiving messages to and from your own programs.

Finding more information

For detailed information about the Canlib API, please see the help file . If you want to know more about a method or some other part of the API while programming in Visual Studio, you can right click on it in your code and select โ€œGo To Definitionโ€.