Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Walkthrough: Using /clr:pure Features 

This walkthrough demonstrates the use of reflection in pure MSIL application. The Windows Forms Scribble solution is extended to include some native classes that contain static data as well as exposing Windows Forms controls that must be usable from the Windows Forms designer. Building the sample with the /clr:pure option addresses potential issues with this scenario. See How to: Migrate to /clr:pure for more information.

To build/run this sample application

  1. Download the ScribbleDotNET sample.

  2. Open the solution file, Scribble.sln, in the Visual Studio development environment.

  3. Build the solution using either the “CLR-Pure Debug” or “CLR-Pure Release” configurations.

  4. Open the StringDialog.h component in Design mode

  5. The design window which appears will contain an instance of the “ScribbleCustomControl”.

  • New C++ Syntax for .NET

  • Reflection

  • marshal_as<T> for access to native types from managed classes

This sample creates an unmanaged class and wraps it in a managed Control class. When compiled into a pure MSIL application, the Visual Studio Windows Forms designer is able to reflect over the resulting EXE file and load the managed control for use in the Windows Forms designer. This behavior is only possible when the current configuration is to create a pure MSIL application, and not in a unmanaged or mixed mode.

Within our Control, we instantiate an instance of a native class and use marshal_as<T> to allow our managed control access to a native data type returned by a call to a method of our native class. Without using marshal_as<T>, we would be unable to access the non-managed data type from a CLR-enabled application.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft