We recommend using Visual Studio 2017

marshal_context Class


The latest version of this topic can be found at marshal_context Class.

This class converts data between native and managed environments.

class marshal_context  

Use the marshal_context class for data conversions that require a context. See Overview of Marshaling in C++ for more information about which conversions require a context and which marshaling file has to be included. The result of marshaling when you use a context is valid only until the marshal_context object is destroyed. To preserve your result, you must copy the data.

The same marshal_context can be used for multiple data conversions. Reusing the context in this manner will not affect the results from previous marshaling calls.

Header file: <msclr\marshal.h>, <msclr\marshal_windows.h>, <msclr\marshal_cppstd.h>, or <msclr\marshal_atl.h>

Namespace: msclr::interop

Overview of Marshaling in C++