新闻资讯

30/07/2015 by Kvaser

Why do I get an exception when running code in Visual Studio?

Some common exceptions are:

FileNotFoundException

FileNotFoundException

This is usually from forgetting to install the driver. The driver is not included with the SDK, but can be downloaded separately from the download section of our website. It is also shown if you don’t have the Microsoft Visual C++ 2010 Redistributable Package installed. These can be downloaded and installed from Microsoft.

BadImageFormatException

BadImageFormatException

This is usually from using the 32 bit version of a DLL in a 64 bit project or the other way around.
This is solved by either changing Platform Target (Project->Properties->Build->Platform Target) to the corresponding architecture, or removing the referenced DLL (Solution->References->canlibCLSNET.dll), and add the correct one.
The DLLs are found in the dotnet folder of the CANlib installation.