"Building and running Delphi for .NET projects using DLite" by Martin Binder

By: Martin Binder

Abstract: The Delphi for .NET preview included with Delphi 7 gives us an excellent peek at the .NET world from the Delphi point of view. This article shows you how to use DLite to help you build, verify and run your Delphi for .NET projects.

Delphi 7 purchasers are privy to a sneak peek at the Delphi for .NET preview compiler, included as a separate CD in the Delphi 7 box. This preview, as outlined in John Kaster's article, gives us access to the Delphi for .NET command-line compiler (DCCIL.exe). This allows us to, in a manner similar to DCC32.exe, compile Delphi for .NET projects from an MS-DOS command-line. Creating these project is left as an exercise for you, the reader, although the new Delphi for .NET Preview Samples web page has some excellent examples. The current release of DLite, the Delphi "Lite" editor, now supports using the Delphi for .NET preview compiler to create and build your .NET projects, all in a familiar GUI environment.

Configuring DLite to use the Delphi for .NET preview

Before running DLite, ensure that both Delphi 7 and the Delphi for .NET preview are installed on your machine. Run DLite, then choose the Environment Options selection from the Tools menu. The Compiler combo box should list "Delphi for .NET Preview" as one of its items. Selecting this item will also cause an "Advanced..." button to be displayed.

Pressing the Advanced button displays the "Advanced Delphi for .NET Preview Setup" screen.

This screen allows you to configure different aspects of the .NET support in DLite. Here you can specify any additional command-line parameters to pass to DCCIL when DLite invokes it. You can also configure the location of PEVerify.exe, and any additional command-line parameters to pass to it. Configuring this allows you to verify your .NET executables directly from the DLite IDE. Finally, you can configure where Reflector.exe is located. As mentioned in John Kaster's article on the Delphi for .NET preview, Reflector is an excellent .NET class browser written by Lutz Roeder. If properly configured, DLite can load your .NET executable into an invoked instance of Reflector for analysis.

Compiling and verifying your .NET projects

Once the compiler has been properly configured, it's time to build your .NET project. As an example, we will work with Borland's ConvertIt sample downloaded from the .NET samples web page. To correctly compile the ConvertIt sample project, you will need to remove the "experimental;" tag from the beginning of Borland.Vcl.Controls.pas. Once you have removed this tag, simply load and build the project as you would any Delphi project.

That's it! Now you can verify your project using PEVerify, simply by pressing Shift+Ctrl+P, or by selecting the "Verify with PEVerify" option from the Project menu. The output from PEVerify will be displayed in the Compiler results window.

You can also bring up your newly built .NET executable in Reflector by pressing Shift+Ctrl+L, or by selecting the "Open Executable in Reflector" option from the Project menu.

Finally, you can now run the .NET application, displaying our favorite temperature converter. 

About the Author

Martin Binder is the founder of Software by Martin, a company dedicated to providing quality tools and components to the Delphi community. He is proud to be a Borland Technology partner and spends most of his spare time dedicated to Delphi. For more information on DLite or the WallCalendar component, you can contact Martin at info@softwarebymartin.com, or visit his Web site at www.softwarebymartin.com.


Server Response from: ETNASC03