Export (0) Print
Expand All

Common Migration Issues

Visual Studio .NET 2003

In this section, some of the most frequently encountered difficulties and misunderstandings of getting started with Managed Extensions for C++ are discussed.

  • The /clr compiler switch is required. Without it, the compiler will not recognize any of the directives, keywords, and data types used in Managed Extensions for C++ programming. For Visual Studio projects, see Adding Support for Managed Extensions for C++ to an Existing Application.
  • .NET modules are referenced with the #using directive. Standard header files cannot be included with the #using directive, and .NET modules cannot be included with the #include directive.
  • All built-in constructs are defined inside namespaces. Furthermore, nested namespaces are used frequently such as System::Collections, System::IO, and System::Text. Reference help topics for .NET types include the namespace in which the data types are defined at the bottom of the topic, but they use the common language runtime dot operator (.) instead of the C++ scope resolution operator (::). Managed Extensions for C++ requires the C++ scope resolution operator.
  • Classes, structs, and enumerations default to native C++ types unless the __gc or __value keywords. (__gc for classes, __value for structs and enumerations.) Alternately, functions are managed by default, but this can be controlled with the #pragma managed and unmanage directives.
  • Data types cannot be passed between managed and native functions without marshaling; casting will not work. The Marshal class provides methods that can be used to marshal data between managed and unmanaged functions.

See Also

Migrating Your Applications

© 2014 Microsoft