Summary

This chapter focused on the methods and techniques available to interoperate with legacy C/C++ unmanaged code that is implemented in DLLs. You learned how to specify the type of marshaling that is required to move your data in the managed world to the unmanaged world using the DllImport attribute. Although many of the samples that were provided were in C#, you saw that it is possible to use these same techniques in many different languages. You learned that with VC++ and the managed extensions it provides, It Just Works (IJW) is an alternative to P/Invoke. Using IJW, you can call unmanaged code without the DllImport attribute. The most significant drawback to using IJW is that you have to explicitly do the marshaling yourself. You learned about the performance hit that P/Invoke requires. P/Invoke doesn't require much overhead, but it does require some, and that could be important to your application. Measure!

The services of P/Invoke are simple and easy to use, but when you need a complex function call, P/Invoke can also handle those needs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.10.137