user206645
user206645

Reputation: 51

Tool for Importing C++ DLL

My company uses a third-party C++ DLL which is updated periodically. I've been manually creating C# DLLImport statements, but in this last update the number of functions nearly doubled. Is there any tool (preferably free) that will create C# DLLImport's from an unmanaged C++ .dll or .lib file? (The DLL exports decorated C++ functions, not C++ class).

Upvotes: 2

Views: 2498

Answers (2)

logicnp
logicnp

Reputation: 5836

As far as I know such a tool does not exist. You must write the P/Invoke declaration for each function yourself. I think its just as well since C++ functions are usually full of subtleties including in/out context, c-style strings, c-style arrays, pointers, references and what not. Many times the expected input/output can only be expressed by documentation and a tool cannot possibly output correct marshalling declarations for the functions.

Upvotes: 0

Dirk Vollmar
Dirk Vollmar

Reputation: 176169

Microsoft's Managed, Native, and COM Interop Team provides some tools on Codeplex, amongst them a tool called

P/Invoke Interop Assistant

I haven't tried it myself, but it looks as if it can do what you are looking for.

Upvotes: 2

Related Questions