Datasheet
is heavily integrated into Component Object Model (COM) and works by exposing only event handlers
as source code to the developer — most of the background code is not available as source code. Not only
that; it does not support implementation inheritance, and the standard data types Visual Basic 6 uses are
incompatible with .NET.
Visual Basic 6 was upgraded to Visual Basic .NET in 2002, and the changes that were made to the lan-
guage are so extensive you might as well regard Visual Basic as a new language. Existing Visual Basic 6
code does not compile to the present Visual Basic 2005 code (or to Visual Basic .NET 2002 and 2003 for
that matter). Converting a Visual Basic 6 program to Visual Basic 2005 requires extensive changes to the
code. However, Visual Studio 2005 (the upgrade of Visual Studio for use with .NET) can do most of the
changes for you. If you attempt to read a Visual Basic 6 project into Visual Studio 2005, it will upgrade
the project for you, which means that it will rewrite the Visual Basic 6 source code into Visual Basic 2005
source code. Although this means that the work involved for you is heavily cut down, you will need to
check through the new Visual Basic 2005 code to make sure that the project still works as intended
because the conversion might not be perfect.
One side effect of this language upgrade is that it is no longer possible to compile Visual Basic 2005 to
native executable code. Visual Basic 2005 compiles only to IL, just as C# does. If you need to continue
coding in Visual Basic 6, you can do so, but the executable code produced will completely ignore the .NET
Framework, and you’ll need to keep Visual Studio 6 installed if you want to continue to work in this
developer environment.
Visual C++ 2005
Visual C++ 6 already had a large number of Microsoft-specific extensions on Windows. With Visual C++
.NET, extensions have been added to support the .NET Framework. This means that existing C++ source
code will continue to compile to native executable code without modification. It also means, however,
that it will run independently of the .NET runtime. If you want your C++ code to run within the .NET
Framework, you can simply add the following line to the beginning of your code:
#using <mscorlib.dll>
You can also pass the flag /clr to the compiler, which then assumes that you want to compile to managed
code, and will hence emit IL instead of native machine code. The interesting thing about C++ is that when
you compile to managed code, the compiler can emit IL that contains an embedded native executable.
This means that you can mix managed types and unmanaged types in your C++ code. Thus the managed
C++ code
class MyClass
{
defines a plain C++ class, whereas the code
__gc class MyClass
{
will give you a managed class, just as if you’d written the class in C# or Visual Basic 2005. The advantage
of using managed C++ over C# code is that you can call unmanaged C++ classes from managed C++
code without having to resort to COM interop.
6
Part I: The C# Language
24727c01.qxd:WroxPro 5/7/07 12:12 PM Page 6