A First Look at Writing and Deploying Apps in The Next Generation Of Windows
Dino esposito
This Article Was Based ON A Pre-PDC Build of Microsoft Windows Code Name "longhorn" and all information contained herein is subject to change.
Download The Code for this article:
Longhorn.exe (113KB)
Note: This document was developed prior to the product's release to manufacturing and, as such, we can not guarantee that any details included herein will be exactly the same as those found in the shipping product The information represents the product at the time this document was. Printed and Should Be Used for Planning Purposes Only. Information Subject To Change At Any Time WITHOUT PRIOR NOTE.
Summary
The next version of the Microsoft Windows operating system, code-named "Longhorn," marks a significant change not only in terms of how the operating system works, but also in the way in which applications are built. The Longhorn version of Windows includes a new storage system, natural search technology, and an increased emphasis on security and trustworthy computing. Here the author provides an overview of Longhorn, focusing on the build-once, deploy n-times application model. In addition, he discusses the new language, Code-named "XAML," That Used to Create Ui Elements, Then Presents Some Working Samples.
he next release of the Microsoft® Windows® operating system, code-named "Longhorn," is an essential milestone for many reasons. It is the first operating system built with managed code and the first to host a new storage subsystem (code-named "WinFS") that revolutionizes the concept of a file system. It is also the first operating system to support a natural search technology (Natural UI) that automatically resolves many of the ambiguities inherent in query text. in addition, Longhorn is the first operating system designed from the ground up with security and trustworthy computing at the core. These and other features suggest that Longhorn will change the way applications are built-not something that happens every day. Since the advent of Windows, I remember two similar milestones-the Move to 32-bit windows and the dawn of the managed environment of the microsoft .NET Framework.one of The Most Important Changes in Longhorn Is That this Operating System Makes It Possible To Write an app lication one time and use it in multiple deployment scenarios. To achieve this ambitious goal, Longhorn-based applications are completely object-oriented and based on a central Application object that provides all key services that are needed for running the application. In this article, I'll Examine The Longhorn Application Model in Some Depth and Apply It to a few Basic Scenarios, Including The Classic Hello World Application.
The Longhorn Application Model
The Application object is the heart of the Longhorn application model. Through its set of properties, methods, and events, the object enables you to arrange a collection of markup pages-a sort of enhanced version of HTML-into a coherent and classic Windows- based application. The Application object is the root application object available in Longhorn. It provides basic application support and will typically be used by those applications that need low overhead and do not use page navigation and state management. More complex Longhorn applications will use the closely related NavigationApplication object, which inherits from Application but adds support for navigation.A typical Longhorn application can be thought of as a set of pages scripted with some procedural code. The Application object controls the execution of the program and raises events to the user code ............................................................................................? lements you control the layout of each page, including the display of text and images and the insertion of interactive components such as buttons and textboxes. In summary, XAML is the language used to declaratively render the user interface of the pages that make up the application . In addition to using XAML, you can also write applications for Longhorn entirely with procedural code. In general, successful Longhorn-based applications have two ingredients-XAML pages and managed procedural code. How you combine them is up to you, but any combination Of The Two is Acceptable.
By using a combination of XAML and C # (or Visual Basic® .NET) code, you can build various types of output files including traditional Windows desktop executables, DLL libraries, and console applications. In addition, if your application is simple enough, it can be rendered using freestanding XAML markup, thus producing another type of application to add to the list. Standalone XAML files are runnable within the Longhorn shell and the browser as long as they do not reference some codebehind class. Finally, it is worth noting that Windows executables can be hosted in a window (by default) as well as in the browser. in both cases, the code remains the same and only needs to be compiled again with a different project property.For Longhorn, desktop executables are the next version of today's Windows Forms client-side apps. On the other hand, XAML and browser-hosted applications represent an evolution of today's client-side programming model to work over the Web. Right now, existing client-si de applications can rarely be deployed over the Web. If you want to embed a Windows Forms form into a browser page, you'll get a reduced feature set and have to tweak bits and pieces of your code. With Longhorn, the common application model Will Let You Write One Application and Deploy It Over The Web. However, The Final Application Is Longhorn-Specific-Very Different from A Traditional Web Application Like ASP.NET.
When you compile an application, the next version of Visual Studio® and the .NET Framework, code-named "Whidbey" (or the underlying MSBuild.exe tool) will produce an .exe file, an application manifest (.manifest), and a deployment manifest (.deploy). If you click on an .exe file, the application runs as expected. If configured to run within a browser, an instance of Internet Explorer starts up and hosts the application. As an alternative, you can also deploy an application from a remote server. The steps to accomplish this are as follows. First, you copy the deployment manifest to the appropriate location on your server. It can be an FTP or HTTP path. Next, you copy the compiled application files and manifests to the appropriate locations on your server. The server-side location of the deployment manifest and the application's files and manifests are not necessarily the same. If they're different, you edit the deployment manifest manually so that it points to the location of The applic ation manifest. Manifest files are plain XML files. When users point their browser to the specified deployment location, Longhorn automatically downloads and installs the application and its manifests on the client computer and creates a shortcut to the .deploy file. At the end of the Process, Users Run The Application By Clicking on The .deploy File.
All Longhorn applications have a common structure-XAML pages with procedural code either inline or codebehind-and the root object derives from Application The Application object acts as a controller;. Its lifetime coincides with the lifetime of the application The Application object allows you to. handle top-level events and sometimes share code and state among pages. It is also responsible for letting the user navigate among pages according to the logic of the application. In a typical Longhorn program, the user performs tasks and progresses through the app by navigating from one page to the next. Navigation is usually accomplished by replacing the old page with the new one. However, you also have the option of opening a new pop-up window to display the new page. Navigation is not necessary in all Longhorn applications Simple Apps That Consist of a Single Page Aren't Going to Need It.AS Mentioned, XAML Pages CAN Contain Procedural Code In Addition To Markup Elements. Procedural Code Is Needed, for Example, To Handle An Event That Is Raised by One of the Xaml Elements on The Paged In The Body CodeBehind File.
Programming in Longhorn is based on managed code. However, only a few .NET-compatible languages can be used to write XAML-based applications. Today the list includes C #, Visual Basic .NET, and JScript® .NET. By the time Longhorn is released, other .NET-compatible languages are expected to be added to the list. The current three-language limit is due to the fact that the source code of a XAML file must be parsed and compiled on the fly, hence a compiler and a related code document object model must be available beforehand. Note, though, that if you write an application entirely in procedural code, you can use any .NET-compatible language for which you can get a valid compiler. Note that only XAML-based apps are lmited to those three languages If procedural code is embedded in a XAML page, then you must compile the application before you can run it;. if there is no procedural code in the XAML page, it can be displayed by double-clicking just AS HTML PAGES Are. Longhorn Doesn't Process Un Compiled Code, Nor Does It Have The Ability To Compile Code on The Ability To Compile What A Longhorn "Hello World" Application Looks Like? Here's A Sample of The Simplest Xaml Code You Can Write: