Preliminary premises writing and deploying applications in next-generation Windows

xiaoxiao2021-03-06  57

This article is based on the version of the Microsoft Windows "longhorn" before the PDC convening, and all the information included here may change.

Please download the code of this article: Longhorn.exe (113KB)

Note: This article is done before the release of the product is put into production, so we cannot guarantee that any details contained here are exactly the same as the details found in the issued product. The description of the product in the article is limited to the product you are published herein, and is only used for planning purposes. The information in this article may change at any time without pre-notice.

Abstract The next version of the Microsoft Windows operating system (codenamed "longhorn"), it not only marks a major change in operating system working methods, but also marks a major change in application construction methods. Longhorn version of Windows includes a new storage system and natural search technology, and more emphasizes security mechanisms and credible calculations. The author provides an overview of Longhorn in this article, the focus of discussion is to build, and can deploy N times application model. In addition, he also discussed the code "XAML" to create a new language for the UI element, and then provided some operation examples.

This page

LONGHORN Application Model Understanding Longhorn Application XAML Language Build Application Example Conclusions

From many aspects, the next version of the Microsoft® Windows® operating system "longhorn" is an important milestone. "Longhorn" is the first operating system built with a managed code, and the latest storage subsystem is first adopted ("Winfs"), this storage system is a revolution in the file system concept. It is also the first operating system that supports Natural Search Technology (Natural UI), which automatically solves many polymity issues inherent in the inherent query text. In addition, Longhorn is the first operating system designed by security mechanisms and trusted calculations as cores. The above information and other features indicate that Longhorn will change the way the application builds - this is not what happens every day. Since Windows came out, I remember that there were two equally important milestones - one is the migration of Windows from 16-bit to 32-bit, and the other is the birth of the managed environment of the Microsoft .NET framework.

The most important change in Longhorn is that this operating system allows the application to encode once in turn and is used in multiple deployment scenarios. To achieve this great goal, Longhorn-based applications are fully object-to-objects, and the entire application is based on a core object Application, which provides all key services required to run applications. This article will lead the reader to experience the Longhorn application model at a certain depth and apply it to several basic examples, including a classic Hello World application.

Longhorn application model

The Application object is the core of the longhorn application model. Through a set of properties, methods, and events of this object, you can use the tag collection - an enhanced version of HTML-to write consistent and typical Windows applications. The Application object is the root application object provided by Longhorn. It provides basic application support, usually used in applications that require low overhead and do not use page navigation and status management. More complex longhorn applications will use closely related NavigationApplication objects, which is inherited from Application, but adds support for navigation.

A typical longhorn application can be considered as a page with some process code to write a script. The Application object controls the execution of the program and generates an event to the user code. The page uses a new declaration mark language to write, the code of this language is "XAML" (Extensible application tag language). With the XAML element, you can control the layout of each page, including the display of text and images, insert buttons, text boxes, and the like interactive components. In summary, XAML is a language used to present a user interface that makes a page that makes an application in a declaration. Of course, in addition to using XAML, you can also use the process code to write longhorn applications. In general, a Longhorn successful application will have XAML pages and managed process code at the same time. You can combine them in your own way, but any combination of both is acceptable. By combining XAML and C # (or Visual Basic® .NET) code, you can build a variety of types of output files, including traditional Windows desktops, DLL libraries, or console applications. Moreover, if your application is simple enough, you can use a separate XAML tag to write it. Thus, another type of application is added in Longhorn. As long as the stand-alone XAML file does not quote the code hidden class, it can run in the longhorn shell (Case) and browser. Finally, the Windows executable can be run either in a window or in the browser. In both cases, the code remains unchanged, as long as the different project properties are recompiled over again.

For Longhorn, the desktop executable is the next version of today's Windows Forms Client Application. However, from the other hand, XAML and apps for the host are also representative of the revolution of the client programming model on the Web. Currently, existing client applications are rarely deployed on the web. If you want to embed the Windows Form into the browser page, the original features will be reduced, you must also modify the code. In Longhorn, the general application model allows you to write a program and deploy it on the web. However, the final application is a very different LONGHORN, which is very different from traditional web applications (such as ASP.NET).

When you compile an application, the next version of the code "whidbey" will generate a .exe file, an application list (extension is. Manifest) and a deployment list (extension is .deploy). If you click .exe file, your application starts running like you expect. However, if you set the application to run in your browser, then after you click the .exe file, you will start an instance of Internet Explorer and run the application. There is also an optional way to deploy an application from a remote server. The steps to complete the deployment are as follows. First, copy the deployment inventory file to the appropriate location of the server. Can be an FTP path or an HTTP path. Then, copy the compiled application files and inventories to the appropriate location on the server. Deployment list, the application's files and the list is not necessarily the same. If they are placed in a different location, you can manually edit the deployment list to point to the location of the application list. The list files are all ordinary XML files. When the user points the browser to the specified deployment position, Longhorn will automatically download the application and its list, and then install them on the client computer, and create a shortcut to the .deploy file. Finally, the user can run the application if you click the .deploy file. All longhorn has a common structure - XAML page with process code (inline or use code hidden) - root object is derived from Application. Application object acts as a controller; its lifecycle is consistent with the life cycle of the application. With Application objects, you can handle advanced events, sometimes you can share code and status between pages. It is also responsible for navigating the user based on the logic of the application. In a typical longhorn program, the user performs the task first, then move forward from a page to the next page in the application. Navigation is usually implemented by replacing the old page with a new page. However, you can also choose to open a new pop-up window to display the new page. Navigation is not required for all longhorn applications; only a simple application including a page does not need navigation.

Just mentioned that in addition to tag elements, the XAML page can also contain process code. Process code is required, for example, an event generated by an XAML element on the page. The process code can be embedded in the body of the XAML file or in a separate code hidden file.

Programming in Longhorn is based on the hosted code. However, there are only several languages ​​with .NET compatible languages ​​to write XAML-based applications. Currently, such languages ​​include C #, Visual Basic .NET and JScript® .NET. Other languages ​​with .NET are also included in the LONGHORN publishing. Currently, only these three languages ​​is that the source code of the XAML file must instantly analyze and compile, so the compiler and related document object model must be ready. However, it should be noted that if you fully use the process code to write applications, you can use any language compatible with .Net, they all have a valid compiler. Note that XAML-based applications can only use these three languages. If the process code is embedded in the XAML page, you must first compile the application before you can run it; if there is no process code in the XAML page, you can display it, just like an HTML page. Longhorn does not deal with uncharacted code, or you can't instantly compile the code. You will not wait to see what the "Hello World" application is like a longhorn version? Below is an example of the simplest XAML code you can write:

XMLns = "http://schemas.microsoft.com/2003/xaml"

Background = "lightcyan"

Width = "100%" height = "100%">

Hello, longhorn!

Figure 1 Simple XAML page

Save this code in a text file and use .xaml as an extension, then point to this file with the longhorn browser or double-click the file in the housing. Figure 1 shows the result. The node defines the user interface area of ​​the application - basically, equivalent to the canvas. The Background property specifies the background color of the area, Width and Height specify the size of the surface. and elements define the contents of this page. These two elements use the LEFT and TOP attributes of the parent Canvas object to define their absolute position.

Back to top

Understand the longhorn app

Longhorn provides a set of expansion and enhances the framework of the .NET framework 1.1. The extensions in Longhorn include: XAML support, storage system, application model, trusted calculation, and advanced web services. In the Microsoft's Roadmap Plan, Longhorn and Whidbey represent two distant milestones. Whidbey is expected to be released several months than longhorn, so when LONGHORN is released, the WHIDBEY upgrade version will be included to provide core services in Longhorn.

Let's take a look at all the foundations of the LONGHORN application - XAML language. XAML language is an XML-based language that is specifically used to describe the user interface of the application. Programmers familiar with the Win32® and .NET framework can see the obvious similarities between XAML tags and traditional Windows controls. However, compared to a full Win32 public control or Windows form control, XAML tag is more abstract, and the range is also wider. In order to quickly understand the meaning of XAML, how you should look at XAML, you can think about the ASP.NET page. Or, more specific, you can imagine an ASP.NET page with only server-side controls (runat = "server"), there is no need to explain with text. Each XAML tag corresponds to a .NET framework class, and includes many methods, properties, and events. You can set the properties and write events directly in the XAML script, or you can use the process code to encapsulate to the code hidden class. The controls hidden after each tag are instantiated at runtime and get one area on the screen to present its output above. From the highest abstraction level, the model is very like ASP.NET, but this model can be used in general, richer Windows platforms.

Each element in XAML uses a basic class, but many classes have no corresponding XAML elements. These classes are often abstract classes that are mostly used in inheritance. Anything created with XAML can be created with process code. For example, use XAML to create a button element, you can use the following code:

转载请注明原文地址:https://www.9cbs.com/read-88671.html

New Post(0)