This page links to help on tasks related to interop using Visual C++. To view other categories of popular tasks covered in Help, see How Do I in Visual C++.
Compares features across the three difference /clr compilation modes.
Discusses issues that arise when compiling native code with /clr and when converting a project to managed.
Discusses how to compile existing MFC and ATL programs to target the Common Language Runtime.
Describes how developers can author applications using a mixture of managed and unmanaged functionality.
Provides guidelines for reducing the effect of managed/unmanaged interop transitions on run-time performance.
Shows how to reference a native type from a managed type.
Shows how, from a managed component, you can call a native function with function pointer parameters where the native function then can call the member function of the managed component's delegate.
Shows how to access characters of a String object for high-performance calls to unmanaged functions that take wchar_t* strings.
Describes how to put a native DLL (not COM) into the Global Assembly Cache.
Shows how to convert between a Guid and a _GUID.
Shows that the most efficient way to convert a char * string to a Byte array is to use the Marshal class.
Shows how convert a Standard C++ Library string (<string>) to a String.
Shows how convert a String to a Standard C++ Library string (<string>).
Describes how to use PtrToStringChars in Vcclr.h to convert String to native wchar_t * or char *.
Shows how to create a gcroot object on the native stack.
Shows how to programmatically check whether an image was built for the common language runtime.
Describes how you can use gcroot.h, which wraps GCHandle, to hold a CLR object reference in unmanaged memory.
Describes how to use gcroot on the boxed type to hold a reference to a value type in a native type.
Describes how you can obtain a pointer to the array block in a Byte array by taking the address of the first element and assigning it to a pointer.
Shows how to define a native type in a /clr compilation and any use that native type from within the assembly.
Shows how to wrap a native C++ class so it can be consumed by code authored in C#, or other .NET language.
Demonstrates using C++ Interop to marshal ANSI strings between managed and native code.
Demonstrates using C++ Interop to marshal Unicode strings between managed and native code.
Demonstrates using C++ Interop to marshal COM strings between managed and native code.
Demonstrates using C++ Interop to marshal structs between managed and native code.
Demonstrates using C++ Interop to marshal arrays between managed and native code.
Demonstrates using C++ Interop to marshal callbacks and delegates between managed and native code.
Demonstrates using C++ Interop to marshal embedded pointers between managed and native code.
Shows how to specify that a function parameter is an out parameter and how to call that function from a C# program.
Describes the available options for using existing COM components from .NET applications and outlines the advantages and disadvantages of each approach.
Demonstrates how COM objects can be used from managed code using the Type Library Importer (Tlbimp.exe) tool.
Demonstrates how COM objects can be used from managed code using Custom Runtime Callable Wrappers.
Describes several tips for writing managed code that interoperates with COM clients.
Explains how native functions that accept C-style strings can be called using the CLR string type System.String using Platform Invoke (P/Invoke) functionality.
Demonstrates how functions that are implemented in unmanaged DLLs can be called from managed code using Platform Invoke (P/Invoke) functionality.
Explains how native functions that accept C-style structs can be called from managed code using Platform Invoke (P/Invoke) functionality.
Explains how native functions that accept C-style arrays can be called from managed code using Platform Invoke (P/Invoke) functionality.
Explains how managed delegates can be used in place of function pointers when interoperating with unmanaged functions using Platform Invoke (P/Invoke) functionality.
Explains how to marshal embedded pointers using Platform Invoke (P/Invoke) functionality.
Shows how you can pass a reference class with a CLR array to a native function, and modify the class, using PInvoke services.
Explains how to extend the marshaling library to provide more conversions between data types.
Explains how you can use the MFC Windows Forms support classes to host Windows Forms controls within your MFC applications as ActiveX controls within MFC dialog boxes or views.
Provides background information about programming differences between Windows Forms and MFC.
Describes how to host a Windows Forms Control as an MFC Dialog Box using the CWinFormsDialog class.
Shows how to create a .NET Framework user control, author the user control in a control class library (specifically, a Windows Control Library project), and then compile the project into an assembly.
Demonstrates how to use CWinFormsView to route commands and update command UI messages to the user control to allow it to handle MFC commands.
Explains why it is advisable to add a member of the user control type and initialize it in IView::OnInitialUpdate.
Describes how to host a Windows Forms User Control as an MFC View.
Explains how to add a user control to a new dialog-based MFC project.
Shows how to bind a native C++ string to a .NET user control.
Shows how to enable native C++ classes to receive callbacks from managed events raised from Windows Forms controls or other forms with the MFC macro map format. Sinking events in views and dialogs is similar to doing the same task for controls.
Describes how to host a Windows Forms user control in an MFC dialog box.