c++.netdllvisual-studio-2022sony-camera-api

Visual Studio 2022 Error when import C++ DLL into C++/CLI project


As the title states, Visual Studio shows an error message when I try to import DLL's into my C++/CLI project. The DLL files are from the Sony camera SDK v1.12.00_20240425a_Win64.

I've tried to import the library a couple of ways:

  1. Right click solution name -> Add -> Reference -> Browse -> Select Files
  2. Add solution containing header files for SDK (project where the DLL files are built from) and add the project to references, but it still doesn't work

Here are some screenshots:

Error message when import dll:

Error message when importing DLL's

C++/CLI project properties:

C++/CLI Proj properties

Project that is using the C++/CLI Project as a ref:

Image Capture Properties


Solution

  • Add -> reference only works with managed DLLs. For native C++ dlls you should usually manually link with the .lib and copy it to the same folder as exe.

    Note: add -> reference can be used for C++ library in the same solution. Project-to-project reference properties:

    When this property is True, the project system links the LIB files that the independent project produces into the dependent project. Typically, you'll specify True.

    For detailed steps, check : To add the DLL import library to your project