Calling Unmanaged code from Managed code
I have an unmanaged C++ DLL, I have the source to. I am trying to extend its functionality. I have successfully called existing methods in the DLL in a brute force way. I simply added the DLL as a project reference to my managed C# project and did a new on the desired class and called the methods.
As I have been studying up on this topic, I ran across the System.RunTime.Interop.Marshal set of static methods. Also, PInvoke. It is not clear to me when I should use one approach over another. I was wondering if someone here could tell me more about them. I am interested in knowing when should you use any of these approaches? when should you not?
My application is a managed wrapper around the unmanaged c++ DLL. The unmanaged DLL is not using COM or ATL. It is just plain C++. I am passing binary data. This data is transformed into another binary data using a complex algorithm and returned. Speed & multithreading is important, since it will be called by several threads.