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).
                +1 
                A: 
                
                
              Microsoft's Managed, Native, and COM Interop Team provides some tools on Codeplex, amongst them a tool called
I haven't tried it myself, but it looks as if it can do what you are looking for.
                  0xA3
                   2010-03-10 11:36:11
                
              Not what I need:  "To use the tool, you either feed in an MSIL assemblies and get out C source for the proper unmanaged signatures or feed in C source with the unmanaged signature and get out proper VB/C#."
                  
                   2010-03-10 12:18:53
                @steve-weeks: As far as I know you will need the C/C++ sources because native DLLs don't store the signature of the exported functions (see http://stackoverflow.com/questions/386133/get-signatures-of-exported-functions-in-a-dll/386488#386488) and even a lib file will store the signature in a compiler specific way.
                  0xA3
                   2010-03-10 13:02:36
                +1 divo @Steve-weeks Presumably you've been using C++ headers from the 3rd party to create the DLLImport statements? Just put those headers into the PInvoke Assistant and it will generat C#
                  MarkJ
                   2010-03-10 13:56:16
                
                
                A: 
                
                
              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.
                  logicnp
                   2010-03-10 13:45:24
                
              Some truth in this, but still a tool like the P/Invoke Interop Assistant can do 90% of the conversion automatically, saving you hours of tedious error prone drudgery.
                  MarkJ
                   2010-03-10 13:58:03