tool to build a wrapper for a C DLL

  • Thread starter Thread starter not_a_commie
  • Start date Start date
N

not_a_commie

Suppose I have some random C DLL. I want to generate a C# wrapper for
it automatically. (By wrapper I mean a large file with a bunch of
[dllimport...] static extern ...., etc.) What tools exist to do this
automatically?
 
not_a_commie said:
Suppose I have some random C DLL. I want to generate a C# wrapper for
it automatically. (By wrapper I mean a large file with a bunch of
[dllimport...] static extern ...., etc.) What tools exist to do this
automatically?


As far as I know there is no such tool, more, if there existed one, I would
not trust it, translating C function calls into DllImport declarations is
something you can only do by hand, even then it's error prone, C function
declarations don't reveal everything you need to know to correctly declare
your DlImport.
Note also that the translation of a function declaration is not that
problematic, translating the data types like structs is the real issue. Note
also, that it's easier to write a managed wrapper using C++/CLI when you
need to import a bunch of native C function into the managed world.

Willy.
 
Back
Top