Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
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.

  • 2 weeks later...
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...