sho Posted August 13, 2004 Posted August 13, 2004 I'am trying call functions from unmanaged dll. NewtonWorld* NewtonCreate( NewtonAllocMemory mallocFnt, NewtonFreeMemory mfreeFnt); void NewtonUpdate( const NewtonWorld* newtonWorld, float timestep); NewtonWorld it's a struct typedef struct NewtonWorld{} NewtonWorld; NewtonAllocMemory and NewtonFreeMemory typedef void* (_cdecl *NewtonAllocMemory) (int sizeInBytes); typedef void (_cdecl *NewtonFreeMemory) (void *ptr, int sizeInBytes); My wrapper: public delegate byte[] NewtonAllocMemory( int sizeInBytes ); public delegate void NewtonFreeMemory ( byte[] ptr, int sizeInBytes ); public class World { internal IntPtr newtonWorld; [DllImport("Newton.dll", CallingConvention=CallingConvention.Cdecl, ExactSpelling = true)] private static extern IntPtr NewtonCreate( NewtonAllocMemory mallocFnt, NewtonFreeMemory mfreeFnt); [DllImport("Newton.dll", CallingConvention=CallingConvention.Cdecl, ExactSpelling = true)] private static extern void NewtonUpdate( IntPtr ptr, float timestep ); public World() { this.newtonWorld = NewtonCreate( null, null ); } public void Update( float timestep ) { NewtonUpdate( this.newtonWorld, timestep ); } When I try create new object i get EntryNotFoundException. Any sugesstions, help. Thx. .Net 1.1 vs2003 Quote
Administrators PlausiblyDamp Posted August 13, 2004 Administrators Posted August 13, 2004 Is the DLL written in C or C++? If C++ then it mangles the names it exports (this is how overloading etc are implemented) Either way you could try using the dumpbin.exe utility on the DLL to make sure the function names are what you are expecting. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
sho Posted August 13, 2004 Author Posted August 13, 2004 Is the DLL written in C or C++? If C++ then it mangles the names it exports (this is how overloading etc are implemented) Either way you could try using the dumpbin.exe utility on the DLL to make sure the function names are what you are expecting. DLL is written in C. Im use dumpbin and function names are NewtonCreate and NewtonUpdate. Quote
Administrators PlausiblyDamp Posted August 21, 2004 Administrators Posted August 21, 2004 Are the functions in the dll using the _cdecl calling convention? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts