I have a dll which comes from a third party, which was written in C++. Here is some information that comes from the dll documentation:
//start documentation
We had this problem when we want to access to DB and solved it by changing EF core to EF 6.4.4 It may be you have a problem like this and need to change or downgrade your version of EF (If you used EF)
First make sure the function is actually exported:
In the Visual Studio Command Prompt, use dumpbin /exports whatever.dll
I solved the same problem in these steps:
step 1) If you program your custom DLL in C++ using Visual studio,then at the property page of your project set the Common Language Runtime Support (/clr)
parameter to Common Language Runtime Support (/clr)
.
step 2) To function deceleration in .h
file use __declspec(dllexport)
keyword like below:
__declspec(dllexport) double Sum(int a,int b);
step 3) Build and export DLL file, then use the Dependency Walker software to get your function EntryPoint.
step4) Import DLL file In the C# project and set EntryPoint and CallingConvention variable like below:
[DllImport("custom.dll", EntryPoint = "?Sum@@YAXHHHHHHNNN@Z", CallingConvention = CallingConvention.Cdecl)]
public static extern double Sum(int a,int b);