Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Click here to receive your FREE subscription to Visual Studio Magazine

email article
printer friendly
get the code
more resources

Build a Longhorn App
Unlike other recent OS releases from Microsoft, Longhorn will have a significant impact on developers. Learn how to create a simple Longhorn app.
by Brent Rector

Posted December 16, 2003

Technology Toolbox: C#, XML

This article is excerpted from chapter 2 of Brent Rector's upcoming book, Introducing Longhorn for Developers [Microsoft Press]. It has been edited for length and format to fit the magazine. You can read a PDF of the full chapter here.

You need to install the Longhorn Software Development Kit (SDK) or the Visual Studio release that supports Longhorn before you can build a Longhorn application. Installing the Longhorn SDK creates a set of Start menu items that you can use to get started. Navigate this path to build Debug versions of your application on a Windows XP 32-bit system: Start | Programs | Microsoft Longhorn SDK | Open Build Environment Window | Windows XP 32-bit Build Environment | Set Windows XP 32-bit Build Environment (Debug).

The primary tool for building a Longhorn application is MSBuild. You can run MSBuild with the help command-line option to get detailed information on its usage:

MSBuild /?
ADVERTISEMENT

Executing MSBuild without any command-line arguments prompts it to search in the current working directory for a filename that ends with "proj." It builds the project according to the directives in that file when it finds one. You can specify the appropriate project file on the command line when you have more than one project file in the directory:

MSBuild <ProjectName>.proj

MSBuild builds the default target in the project file by default. You can override this and specify the target you want build. For example, you invoke MSBuild to build the target named CleanBuild:

/t:Cleanbuild

I'll show you how to write your first program—Hello World, in the grand tradition of programmers everywhere. First, define the Application object. You do this typically in a file called the application definition file. This HelloWorldApplication.xaml file defines the Application object:

HelloWorldApplication.xaml
<NavigationApplication xmlns=
   "http://schemas.microsoft.com/2003/xaml" 
   StartupUri="HelloWorld.xaml" />

This text asserts that you want to use an instance of the MSAvalon.Windows.Navigation.NavigationApplication class for the Application object. On startup, the application should navigate to and display the user interface (UI) defined in the HelloWorld.xaml file. The HelloWorld.xaml file contains this information:

HelloWorld.xaml
<Border xmlns=
   "http://schemas.microsoft.com/2003/xaml">
   <FlowPanel>
      <SimpleText Foreground="DarkRed" 
      FontSize="14">
      Hello World!</SimpleText>   </FlowPanel>
</Border>

You have the "code" you need for a simple Hello World application. Next, you need a project file that defines how to build the application (see Listing 1).




Back to top













Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTPOnline Home