hi! I'm trying to get the following C++ class (contained in a DLL):
__declspec(dllexport) class ThreadManager {
public:
__declspec(dllexport) static UINT32 setThreadPriority(UINT32 tPriority);
__declspec(dllexport) static UINT32 setPriorityClass(UINT32 pClass);
__declspec(dllexport) static UINT32 setProcessorMask(UINT32 pAffinity);
__declspec(dllexport) static UINT32 changeMATLABSeed(UINT32 inputSeed);
static BOOL setHandles(HANDLE* thread, HANDLE* process);
__declspec(dllexport) static BOOL testFun(UINT32 testInt);
static UINT initializeProgram(ostream* consoleStream);
};
into C#... in which I have the following class:
class ThreadManagerWrapper
{
[DllImport("MATLABCPPThreadLibrary.dll", CharSet = CharSet.Auto)]
public static extern UInt32 setThreadPriority(UInt32 tPriority);
[DllImport("MATLABCPPThreadLibrary.dll", CharSet = CharSet.Auto)]
public static extern UInt32 setPriorityClass(UInt32 pClass);
[DllImport("MATLABCPPThreadLibrary.dll", CharSet = CharSet.Auto)]
public static extern UInt32 setProcessorMask(UInt32 pAffinity);
[DllImport("MATLABCPPThreadLibrary.dll", CharSet = CharSet.Auto)]
public static extern UInt32 changeMATLABSeed(UInt32 inputSeed);
[DllImport("MATLABCPPThreadLibrary.dll", CharSet = CharSet.Auto)]
public static extern Boolean testFun(UInt32 testInt);
};
everything compiles fine... but when I call ThreadManagerWrapper.testFun(1);
everything crashes, and VS 2005 informs me:
Unable to load DLL 'MATLABCPPThreadLibrary.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I've been reading a selection of tutorials on creating wrapper classes or doing p/invokes... and I think I've created a monster...
anyone out there familiar with C++ -> C# interop wanna give me a step-by-step on how to wrap my C++ code? or perhaps want to give me a link to a /good/ tutorial? (seriously... most of them out there are utter crap ;_; )