Can't find PInvoke DLL

  1. Please anyone can help how to import the third party dll in Toradex Smart device application.
  2. There is only “Any CPU” in platform target of Toradex Smart device application. How can we change it to x86 ?

There is a issue of “Can’t find PInvoke DLL” even the DLL exists in correct path;
[DllImport(@“SD Card\Path…\HikVisionLibrary\HCNetSDK.dll”)]
public static extern bool NET_DVR_Init();
m_bInitSDK = CHCNetSDK.NET_DVR_Init();
Please have a look the below image of error message

@Dhananjay

I think there is some server issue, the attachment is not working, can you upload the image here: https://share.toradex.com/ and share the link.

Please find the image from this link

Hi,

when you build and use C++/C dll they depend on the C runtime dll (msvcr100*.dll)
They are not part of the Toradex image, but they can easily be found in the Visual Studio installation for the Arm target.
To access Dll’s from .NET with Pinvoke, the C runtime dll need to be present, because the exported function in the Dll, is export as C function (Hence: The need for the C runtime dll’s).

What my requirement is to integrate the camera say CPPlus / HikVision in Colibri T20 smart device winForm. For this what I do is, import the Dll which are developed in C++ enter code here
[DllImport(@“FlashDisk\CameraDll\HikVisionLibrary\HCNetSDK.dll”)]
public static extern bool NET_DVR_Init();

and have placed all Dlls in "FlashDisk\CameraDll\HikVisionLibrary" but when I access the method “NET_DVR_Init()” this issue has come Can't find PInvoke DLL 'FlashDisk\CameraDll\HikVisionLibrary\HCNetSDK.dll'.

please help me how to resolve.

Could you first try and place the DLLs to same directory as your application? And than use DLLImport without path. This would explain if its path or DLL issue.

Yes Luka, I have tried with Dll placed in the same directory of the application exe and not worked. But the same scenario is working in normal winform with x86 target platform.
Please let me know if there is any way to change the target platform to x86 in smart device application, by default there is only option of “Any CPU”.

If you are using Toradex module you can’t change it to x86, The Toradex modules are ARM based CPU’s.

Is the HCNetSDK.dll build for the ARM CPU or X86?

HCNetSDK.dll build in x86 and is perfectly working with X86 application.

If your DLLs are built for X86 then they will not load on ARM platform. I did some googling and could not find this DLL in ARM mode. Do you use same DLL on PC and our module? If yes than its for sure built for x86 and wont run on ARM modules

Then it is but obvious, X86 built application/DLLs will not going to work for ARM you need to cross compile for ARM platform, then it should work on T20 module.