I would like to use a few functions of a .dll to manage a EVB of Digilent (Basys2).
The manufacturer provides me the next files:
dpcdefs.h
dpcutil.h
dpcutil.lib
Besides the dpcutil.dll that it's installed in c:/windows/system32
The function I am trying to use apperas in the header file dpcutil.h:
..... DPCAPI BOOL DpcInit(ERC * perc); ....
And in the file dpcdefs.h appears defined the type ERC. It's a int:
.... typedef int ERC; /* Error code type */ ....
The type BOOL is:
.... #define BOOL unsigned int ....
I've got to use a few more functions but I don't manage to use this one property. I made a class to manage this function:
class Dpcutil
{
public Dpcutil() { }
const string _dllLocation = "C:\\Windows\\System32\\dpcutil.dll";
[DllImport(_dllLocation)]
public static extern uint DpcInit(ref int perc);
}
The program compiles correctly, but when I execute the function DpcInit The program fails:
Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'D:\SVN\sfa\trunk\sw\digilent_parallel_interface_module_test\digilent_parallel_interface_module_test\bin\Debug\digilent_parallel_interface_module_test.vshost.exe'.
Additional information: A call to PInvoke function 'digilent_parallel_interface_module_test!digilent_parallel_interface_module_test.Dpcutil::DpcInit' correspondence prevented stack. Perhaps the reason is that the managed PInvoke signature does not match the target unmanaged signature. Check that the convention and parameters of the PInvoke call signature match the target unmanaged signature.
I don't know if I 'm using correctly the DllImport.