Chapter 13. Advanced Interaction

Chapter 12 showed you how to use Platform Invoke to call unmanaged functions defined in dynamic-link libraries (DLLs). For simple functions, the procedures outlined in the previous chapter will work very well, but you will come across cases that demand more advanced techniques.

This chapter will show you how to use unmanaged functions that take string arguments or array arguments, or require pointers to be passed. It will also show you how to pass pointers to managed objects into unmanaged code, and how to specify the path to a Platform Invoke DLL dynamically.

The MarshalAs Attribute

You use this attribute to specify how data should be marshaled between managed and unmanaged code when you need to override the defaults. ...

Get COM Programming with Microsoft® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.