C# and unmanaged C++ DLL


Is there a way to use an unmanaged C++ DLL in C#?

I've tried "converting" the DLL using tlbimp.exe to a RCW. But this gives a an error that it isn't a valid type library.

I've also used the metatag [dllimport()], this gives more result, but not correct(correct text but with preceding strange characters). I've tried using a function that.

Anymore tips on creating the DLL or C# calls?

The reason why it is a unmanaged C++ dll, is because of the files, provided by another company must be used. I've just created a few callable function to use the functions.



  • Another DLL written in C++/CLI would give you a lot of control over the managed to unmanaged calls. It would be a mixed-mode library that links to the unmanaged DLL and exposes the required methods to the C# program through your own classes.

    It's not the easiest approach, but it's more flexible and faster than the dllimport method. I've done this for several projects with great results.
  • By mixed mode you mean(starting from the class with entry point, C#):
    1: C#
    2: C++/CLI(DLL)
    3: Unmanaged C++(DLL)

    I'm gonna try this solution. I hope i don't get confused working with all these types ;)...
    To be continued;
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!