Core Concepts

Visual Studio.NET

Producing .NET applications and components requires a compiler that translates source code into IL code. VS.NET, Microsoft's new version of Visual Studio, contains three such compilers: VB.NET, C#, and managed C++. While a full examination of these languages is beyond the scope of a CodeNote, each language is briefly discussed below. Code examples throughout this book will demonstrate some of the nuances of each language and the syntactical differences between them.

In addition to the IDE, VS.NET contains a large assortment of command line utilities. Some of these utilities are directly incorporated into the development environment, while others are stand-alone. We will examine some of these utilities throughout this CodeNote.

Visual Basic.NET

VB.NET is the most recent version of Visual Basic, what was once thought of as VB7. VB.NET is the first version of Visual Basic to support true object-oriented inheritance, which means it has the ability to inherit and extend the interface and behavior of any class produced by an IL compiler. This is significant, as previous versions of Visual Basic could only inherit from classes written in VB itself. This feature is not really an enhancement of VB.NET but a byproduct of the language neutrality of the CLR, which gives all IL compilers the ability to inherit classes from one another. VB.NET also includes exception handling constructs (try/catch) similar to those found in Java and C++.

Unfortunately, VB.NET also brings about some syntax changes that will break compatibility with old VB source code. Procedure parameters, for example, are now passed by value (ByVal) by default, not by reference (ByRef). Certain syntax elements such as GoSub, IsNull, and IsMissing have been removed from the language altogether. For a complete list of syntax changes, see aNET010002. Clearly, a considerable amount of effort will be required to migrate existing Visual Basic projects to the .NET Framework.

Although not exclusive to VB.NET, most VB users will be interested in the Windows Forms (Chapter 7) portion of this book, which investigates the new way Win32 screens are developed in the .NET Framework. Windows Forms completely replaces the traditional Visual Basic

Forms editor. Finally, VB.NET now ships with a command line compiler (VBC.EXE), allowing one to write applications outside the development environment (using NOTEPAD, for example). In the first example in this chapter, we will investigate VB.NET's new compiler.

Managed C++

Managed C++ is a set of extensions added to the C++ language to allow one to produce "managed code" (code that executes under the auspices of the CLR). The most notable extension is the introduction of "managed types," which shift the burden of memory management from the

C++ programmer onto the CLR. Placing the_gc extension in front of the declaration of a class, for example, allows instances of the class to be garbage collected by the CLR. This convenience comes at a cost, however, as the "managed" class must adhere to the restrictions of CLR types. It cannot, for example, inherit from two classes, even though multiple inheritance is a feature of the C++ language.

Another extension is that of managed arrays, which allows these data structures to be managed by the CLR. Managed exception handling is another amendment, differing from C++ exception handling in both syntax and behavior. Examples of managed extensions can be found at aNET0l0003. Managed C++ is a part of Visual C++ .NET, which is the only tool in the new Visual Studio suite capable of producing unman-aged code. It is thus the only choice for producing applications that contain both managed and unmanaged code, as is discussed in the online article at ^net010010.

C# (pronounced "C-sharp") is a new language that Microsoft has touted as a simplified version of C and C++. In this respect, C# is very much like Java, eliminating some of the more complex features of C++ such as pointers and multiple inheritance. Most of the examples in this CodeNote are written in C# (and VB.NET), to give you a look at this new language. Like Java and C++, C# is an object-oriented (OO) language and contains expected OO features such as inheritance (the ability of a class to extend another class), polymorphism (the ability to separate an interface from its implementation), and encapsulation (the ability of objects to hide certain methods and instance variables from other objects).

Java and C++ developers will be immediately comfortable with C#, while the language may present some challenges for Visual Basic developers. Even if you choose to develop in another language under the .NET Framework, it is worthwhile to understand C#, as the majority of MSDN .NET code is written in C#. In this sense, C# can be considered the "intrinsic" language of the .NET Framework, as it was developed solely for the managed environment, as opposed to C++ and Visual Basic, which had to evolve into their .NET manifestations.

.NET and COM

While the .NET Framework is intended to simplify many of the complexities that existed with COM, it in no way renders COM obsolete. All versions of Windows today remain heavily dependent on COM, and while Microsoft's long-term vision may be to eradicate this component model, it is not going anywhere soon. Chapter 5 will investigate how .NET applications can call traditional COM components using Runtime Callable Wrappers (RCWs).

COM+ services such as transactions, object pooling, and Just-in-Time activation can be used from the .NET Framework and are accessed through the System.EnterpriseServices namespace. Examples of managed code using these services can be found at aNET010004.

The .NET Runtime also implicitly uses COM+ to support some of its services. In the Transactions section of Chapter 6, we will see how the .NET Runtime automatically uses COM+ services behind the scenes to provide transactional capability for managed classes.

0 0

Post a comment

  • Receive news updates via email from this site