This is the first post in a 3-part series about CANlib development:
- Setting up CANlib in Visual Studio
- Basic API Calls
- Event Driven Applications
Intro
Welcome to our guide on how to setup a Visual Studio C# project to use the Kvaser CANlib Software Development Kit.
Before beginning please make sure that you’ve installed CANlib and our latest drivers. In addition to the Visual Studio C# tools, you will need to install the Microsoft Visual C++ redistributable package. This package is necessary because the managed CANlib Dynamic Link Libraries are created using C++.
Example
For our example we are going to create a Windows C# console application. To do this, we will launch the New Project wizard by selecting the New Project link from the Start Page. Once the wizard is open, select Windows Desktop under Visual C#, in the Templates tree. Select Console Application from the template list. You may also choose your desired .NET framework from the drop menu above the available templates list. We need to create an application name and select a location for the project to be saved. Finally, press OK and Visual Studio will create the solution directory and associated project files.
Once the project has opened, right click on the project file in the Solution Explorer. Select Properties, then under the Application tab, make sure that the Target Framework has the desired Framework version. Next we move to the Build tab to set the Platform Target. First change the Configuration to “All Configurations,” then select the desired Platform Target. The Platform Target cannot be set to Any CPU. The CANlib Dynamic Link Libraries are created using C++ which requires a specific target platform. Therefore, you must select a Platform target for your project of x86 or x64. For this example, we will choose x64.