Chapter 1.4. Working with Managed Extensions to C

I l @ ve RuBoard

Chapter 1.4. Working with Managed Extensions to C++

IN THIS CHAPTER

  • The C++ Extension Keywords

  • Using the C++ Compiler for Managed C++

  • Garbage Collected Classes

  • The #using Directive

  • The String

  • Mixing Managed and Unmanaged Code

  • Pinning Managed Code

  • Managed Interfaces

  • Creating Value Types

  • Creating and Using Delegates

  • Calling Custom .NET DLLs from Your Managed C++ Code

  • Using Managed and Unmanaged C++ DLLs in Your .NET Programs

  • Using Properties in Your C++ Classes

  • Ensuring the Alignment and Packing of Your C++ Structures

In the previous chapter we looked briefly at managed extensions to C++ as a way to use your C++ skills, either in the managed environment of .NET or as a vehicle for reusing your existing code. If you're the typical C++ programmer looking at migration to .NET, the questions foremost in your mind will be "Can I protect my investment in all that C++ code?" and "Can I use C++ and C# together easily?" Thankfully, due to the efforts of the Microsoft engineers , both of these questions have positive answers. Let's take a short sidetrip into managed extensions to C++ and get a feel for where your old code can fit into the new world of .NET.

The managed extensions add a few keywords to the C++ language. Obviously this is not going to amuse language lawyers the world over, but remember that in reality, managed C++ is not an attempt to corrupt ANSI specifications but a compromise that allows many of the benefits of the managed runtime without the pain of having to learn a whole new language. As an aside, the Visual Studio.NET C++ compiler is actually more ANSI compliant than its predecessors when used in native C++ mode. When used to compile ordinary C++ code, the compiler generates x86 object code for linking in the normal manner. When used to compile managed C++, the /CLR command-line argument is used, and the compiler creates IL instead.

I l @ ve RuBoard


C# and the .NET Framework. The C++ Perspective
C# and the .NET Framework
ISBN: 067232153X
EAN: 2147483647
Year: 2001
Pages: 204

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net