Delphi 8 - Migrating Delphi applications to the Microsoft .NET Framework with Delphi 8.pdf
(
768 KB
)
Pobierz
Migrating Borland
Delphi
applications to the Microsoft
.NET
Framework with Delphi 8
A Borland White Paper
By Bob Swart (aka Dr.Bob),
Bob Swart Training & Consultancy (
http://www.drbob42.com
)
February 2004
Migrating Borland
Delphi
applications to the Microsoft
.NET Framework with Delphi 8
Contents
Introduction......................................................................... 3
Delphi
7 to Delphi
for the Microsoft
.NET Framework .......... 3
VCL, VCL for .NET, and Windows
Forms ........................................................................ 4
Delphi
7 language and RTL not available in Delphi
for Microsoft
.NET .................................. 5
Unsafe code ...................................................................................................................................... 7
New language features ..................................................................................................................... 8
Delphi
7 VCL components not in Delphi
for the Microsoft
.NET Framework .......................... 8
VCL to VCL for .NET ............................................................. 9
VCL applications .................................................................................................................. 9
Ownerlist ........................................................................................................................................ 10
ConvertIt ........................................................................................................................................ 11
AppEvents ...................................................................................................................................... 12
VCL for .NET deployment ................................................................................................. 13
Database applications.......................................................................................................... 14
Data Access components ................................................................................................................ 15
FishFact (BDE) .............................................................................................................................. 16
Frames\Db (Frames and BDE) ....................................................................................................... 16
dbExpress ....................................................................................................................................... 17
Web applications.................................................................19
Web Services ......................................................................20
Miscellaneous .....................................................................20
Summary.............................................................................21
References........................................................................................................................... 22
2
Migrating Borland
Delphi
applications to the Microsoft
.NET Framework with Delphi 8
Introduction
With the release of Delphi
8 for the Microsoft
.NET Framework (a.k.a. Delphi for .NET),
Borland has enabled Delphi developers to target another new platform, supporting the needs
of its developer base. Previous versions of Delphi can produce Microsoft
Win32
applications (and with Borland
Kylix,
we can build Linux
applications using the Delphi
language).
Delphi for .NET enables developers to write native .NET applications using Windows
Forms
or Web Forms as the framework, or using VCL for .NET components.
This paper discusses the migration of Delphi applications for Win32 to the Microsoft .NET
Framework using Delphi 8 for the Microsoft .NET Framework. The difference between
Windows Forms and VCL for .NET is covered, as well as several sample migrations from
existing Delphi Win32 VCL applications to Delphi for .NET native .NET applications.
Delphi
7 to Delphi
for the Microsoft
.NET
Framework
Using Delphi for the Microsoft .NET Framework, we can compile applications that were
made in Delphi 7 or previous versions. The Delphi 8 box also includes Delphi 7 to produce
Win32 applications. If you want to produce source code that compiles with both Delphi 7 to a
Win32 target and with Delphi for .NET to a .NET target, then you might need to use compiler
IFDEFs inside your source code.
Delphi 7 contains the following compiler defines:
MSWINDOWS
WIN32
3
Migrating Borland
Delphi
applications to the Microsoft
.NET Framework with Delphi 8
Delphi for .NET contains the following compiler defines:
CLR
CIL
MANAGEDCODE
This means that you might want to write code like the following (using the Linux
compiler
define to complete the Delphi platform alternatives):
project
HelloWorld;
{$APPTYPE CONSOLE}
begin
{$IFDEF CLR} // Delphi for .NET
writeln('Hello, .NET world!');
{$ENDIF}
{$IFDEF WIN32} // Delphi 7
writeln('Hello, Win32 world!');
{$ENDIF}
{$IFDEF LINUX} // Kylix
writeln('Hello, Linux world!');
{$ENDIF}
end.
Note that we now have three possible platforms, so you should not use {$ELSE} to write
code that is not suited for one particular platform. Even if you are certain today that the code
is right, future support for other platforms might break your code. Always use specific
{$IFDEF} sections to write code for a specific platform.
VCL, VCL for .NET, and Windows
Forms
When Delphi first shipped in 1995, the component library was called the Visual Component
Library. It contained more than just visual components, however. A number of these
components are platform-independent, and it was mainly the visual components that were
specifically bound to the Windows API and controls.
4
Migrating Borland
Delphi
applications to the Microsoft
.NET Framework with Delphi 8
When Kylix was introduced, a new library name was used: CLX (Component Library for
X-platform), which divided the components in BaseCLX, DataCLX, VisualCLX, and
NetCLX. Using Delphi 6 and 7, we can build visual applications using CLX (VisualCLX is
cross-platform for Linux and Win32) or VCL (only on Win32).
Now that Delphi has been ported to the Microsoft .NET Framework, the VCL has been ported
to .NET as well. This means that we can not only use native Windows Forms to produce
.NET applications with Delphi for .NET, but also VCL for .NET to produce .NET
applications. Because VCL for .NET uses the same classes and property/events interfaces that
the VCL for Win32 uses, Delphi Win32 projects can be migrated to Delphi for .NET with
considerable ease, which will be demonstrated in this paper).
CLX, VCL, and VCL for .NET are similar in terms of class names, property/event names, and
their usage. They all use an external stream file to place the property and event assignments:
for CLX an .xfm file, for VCL a .dfm file, and for VCL for .NET an .nfm file. In contrast, the
Windows Forms projects do not rely on a .nfm file, but assign all property and event handler
values in source code (hence the need for code folding in the IDE).
The VCL can be seen as a wrapper around the Win32 API, and the VCL for .NET can be seen
as a wrapper around the .NET Framework (or more specifically the Windows Forms classes).
The move from VCL to VCL for .NET is fairly painless and involves far less work than the
move from the Win32 API to the .NET Framework with Windows Forms. And the future
move to Longhorn's XAML (for the new Avalon presentation layer) will also be easier when
using VCL than when bound to a native layer such as the Win32 API or Windows Forms. In
short, using VCL extends the lifetime of your code.
For more information about VCL, CLX, and Windows Forms, see John Kaster's article at the
Borland Developer Network at
http://bdn.borland.com/article/0,1410,29460,00.html
.
Delphi
7 language and RTL not available in Delphi
for Microsoft
.NET
Although the move from VCL to VCL for .NET is fairly painless, several migration issues are
related to the differences in the Win32 and .NET platforms. These issues are related to the
fact that .NET code is executed by the CLR in a safe, managed way, so all potentially unsafe
5
Plik z chomika:
musli_com
Inne pliki z tego folderu:
Delphi 8 - Migrating Delphi applications to the Microsoft .NET Framework with Delphi 8.pdf
(768 KB)
index.html
(5 KB)
Inne foldery tego chomika:
Delphi
Delphi 2005
Delphi 5
Delphi 6
Delphi 7
Zgłoś jeśli
naruszono regulamin