Friday, September 30, 2005

RSS Support in Longhorn

Browse, Search, Subscribe: The Promise of RSS
Introducing RSS Support in the Longhorn Platform
Scenarios
Architectural Overview
How to Enable RSS in Your Application
Feedback
References

Summary: This paper describes RSS in the context of a vision for how Web content is and will be consumed, explores opportunities enabled by incorporating RSS functionality into applications, and outlines the Windows platform services that make this easy. (13 printed pages)

Browse, Search, Subscribe: The Promise of RSS

With increasing adoption of RSS, the concept of "subscribing" to content on the Web is becoming more prevalent. As this idea continues to gain in popularity, users will be able to subscribe not only to blogs and news, but also to content feeds (audio, video, documents, photos, calendar events, and so on) and lists (play lists, book lists, link lists, blogrolls, wish lists, top-10 lists, to-do lists, and so on). The next version of Windows, code-named "Longhorn," introduces rich support for RSS in the platform.

As the Web increases in content and usage, the way that users interact with it has become increasingly sophisticated.

Browse

Browsing has always been the centerpiece of the Web experience. Typing in URLs and following links remains the primary way to find and consume information.

Search

Increasingly, users have learned to rely on sophisticated search engines to help them navigate the abundance of content and information that the Web has to offer. For many, search has become the primary way to begin navigating the Web.

Search is the first step on the road of harnessing the power of computers to do work on the user's behalf.

Subscribe

More recently, smart software is enabling an increasingly sophisticated and powerful model of interacting with the Web: After finding interesting information, users are using RSS technologies to "subscribe" to the content, ensuring that the latest changes or updates to the content are delivered to them, instead of having to return to the site to check it again.

This model of subscribing to content is pervasive, both within the technical community, and in other areas. Once users get used to it, they want it everywhere. In a similar way, users of a PVR (Personal Video Recording) device for TV will often claim that they'll "never watch TV the same way again."

RSS Today

The widespread usage of RSS heralds a shift to the new model of subscription. One estimate holds that there are over 60 million blogs worldwide as of April 2005 (including 14 million hosted by MSN Spaces), a majority of which are available via RSS (or similar formats). Every major online news site syndicates their news stories via an RSS feed, and several other sites are making their content syndicated via RSS. The impact of RSS cannot be denied.

Today, RSS is primarily used for news sites and blogs, and increasingly for audio-based serialized content—but it has the potential both to have broader reach and to more deeply integrate the information it delivers across applications of various kinds.

About the Format

To understand a little more about how (and why) RSS works, we must take a look at the format. RSS, as we use it in this document, refers not to a single format (such as RSS 2.0), but to the general concept of feeds of syndicated content. It should be considered to cover all feed formats that meet the basic criteria of updateable collections of items.

The most popular format, and the standard format used in most of the descriptions in this document, is RSS 2.0, authored by Dave Winer (see references). RSS 2.0, like most of the other RSS feed formats, is a simple XML-based format originally intended for syndicating or summarizing content that is available on a Web site.

An RSS feed typically contains the most recent items published on that Web site. For example, a news Web site may make summaries of stories available via an RSS feed on its Web site. A blogger may make available an RSS feed of the most recent articles he has posted to his blog.

RSS 2.0 also includes a simple extension mechanism that allows publishers and clients to define additional elements to include in a feed. RSS 2.0 also introduced the concept of enclosures—a lightweight way of attaching a file to an item within a feed.

One reason behind the success of RSS is both its simplicity and breadth. RSS 2.0 has a simple vocabulary consisting of just a handful of XML elements. These elements are good at representing everything from software updates to news articles to blog posts. This flexibility has made it possible for a diverse collection of sites to adopt RSS for various needs.

Introducing RSS Support in the Longhorn Platform

The Longhorn platform support for RSS focuses on enabling developers to build applications that support the core RSS scenarios described above, as well as more advanced applications of the RSS specification. Longhorn also leverages the RSS extension model for enabling new scenarios.

Platform Components

The RSS platform support in Longhorn has three parts:

  • Common RSS Feed List gives application developers access to the list of feeds to which the user is subscribed.
  • Common RSS Data Store is a common data store that provides a single location where applications can access any content that has been downloaded to the PC via RSS—including text, pictures, audio, calendar events, documents, and just about anything else. All applications will have access to this content for creating rich user experiences.
  • RSS Platform Sync Engine automatically downloads data and files (enclosures) for use by any application. It is designed to be as efficient as possible when downloading this information, using idle network bandwidth whenever possible, in order to limit the impact on the user's Internet experience. Developers can use the platform to get RSS data without having to manage details like synchronization schedules or subscriptions.

Discovery and Subscribe

While browsing the Web, users will be able to easily discover RSS feeds through an illuminated icon, as well as read the feed while still in the Web browser. Additionally, users will be able to subscribe to an RSS feed as easily as they now add a Web page as a favorite. Once a user chooses to subscribe to a feed, the fact that the user has subscribed is available to any interested application.

This feature is enabled by the Common RSS Feed List. This core feature of Windows maintains a common list of the user's subscriptions across all applications. This allows the user to subscribe to a feed once and all RSS-enabled applications can access the common list to view the user's subscriptions.

For instance, a contact management application can automatically expose a subscribed feed containing people information as a new group in the application. Similarly, any application can add new feeds to the feed list.

Enabling New Scenarios with Enclosures

In addition to the common feed list, the Longhorn platform provides powerful platform services to enable application developers to easily harness the capabilities of RSS in their applications. In particular, RSS allows the publisher to attach files (known as enclosures) to each item in the feed that can be consumed by RSS-enabled applications.

For example, a business user about to attend a conference could subscribe to the conference's event calendar. He can then use a Longhorn RSS-enabled calendar application to view the events in the RSS feed from within his calendar app.

Enabling New Scenarios for Lists

Many collections of interesting content are actually not time-ordered; they are sorted by such properties as priority, cost, or simple ranking. In fact, one can observe these lists everywhere in one's daily life: to-do lists, shopping lists, sales reports. On the Web, one can readily observe lists of this type: Top 10 songs from a music site, a wish list from an online retailer, or a user's ranking of their favorite restaurants. In many cases, one can imagine wanting to subscribe to these lists and be notified when the content is updated. In fact, some of these lists are already being published as RSS.

However, in practice, RSS is not particularly well suited for describing lists of ordered content. In part this is because clients do not understand that the feed being received represents a complete, ordered list, and process it as if it were a time-ordered feed, resulting in incorrect behavior.

Longhorn includes support for the Simple List Extensions—a set of enhancements to RSS developed by Microsoft to help Web sites publish lists of content that users can subscribe to.

The Simple List Extensions expands the scope of RSS in two significant ways:

  1. The extensions enable RSS to capture information critical to representing lists, such as the ordering of items. By using these extensions, applications can recognize that a feed is more than just a feed—it is a list and the client should apply different rules with respect to changes (such as an item that was moved up or down or was removed from the list altogether).
  2. The extensions allow publishers to embed useful information about the list itself. For example, an online retailer can supply additional information about each item in a wish list, such as price, sales rank, average customer rating, and type of merchandise. The extensions provide a general mechanism for declaring that these additional properties are useful pivots for sorting and ordering. This allows the user to sort their friend's wish list by the sales rank of the item or to find the most popular item on the list.

Longhorn's support for the Simple List Extensions enables users to subscribe to lists and enables the publishers to provide guidance to the clients about how their lists should be manipulated. These extensions make these interesting and useful lists much more accessible to users.

Web sites that create lists using the Simple List Extensions will benefit as well; for example, a music site will be able to deliver a daily top-ten–most-popular-tracks list to drive increased sales.

See the References section for the Microsoft Simple List Extensions 1.0 specification.

Scenarios

The RSS support in Longhorn opens up limitless array of opportunities for publishers and application developers to create new experiences for end-users or to integrate updatable content delivered via RSS into their applications.

The diagram below shows how the existing RSS scenarios (blogs, news, and podcasting) can be expanded in interesting new dimensions with the addition of the concept of list feeds (supported by the Simple List Extensions), and by clearly defining how the existing RSS extension mechanism can be used to extend the definition of an item within an RSS feed.

Figure 1. Feed and lists in RSS

Feed Scenarios

The left-most column covers scenarios based on time-sorted feeds. The RSS support in Longhorn gives developers the ability to enable any of these scenarios in their applications.

One scenario might involve interacting with a feed that contains calendar information. For example, a user wants to attend a business conference:

  • On the conference's Web site, the conference organizer has made available a feed of calendar data. Whenever there are updates to the overall schedule, the publisher simply updates the feed.
  • The user can subscribe to the schedule feed. Their calendar program can automatically show them the events provided by the conference organizer.
  • If the location for a sessions changes, it's automatically updated in the user's calendar the next time she connects to the Internet.

In another example, a school might publish their calendar of events on the school's Web site:

  • Parent meetings, plays, and other activities can appear as events in this feed.
  • Parents can subscribe to the calendar and have the events automatically appear on their calendars as soon as the school schedules them (and therefore not having to rely on the school contacting them, or the child informing them).
  • The school might even allow feeds tailored to individual students, so that the information in the parent's calendar includes the student's after-school activity schedule allowing the parent to know what time the child is finished each day, so that he can pick them up.

Another scenario might involve a digital photo management application. For example, a couple having their first child might want to share the pictures of their baby with their family in other countries:

  • The couple creates a photo blog and posts pictures of their baby at various stages of its growth.
  • A family member in another country can subscribe to a photo blog and have pictures of the new baby automatically downloaded. Any time new pictures are posted, they are automatically viewable in a photo library or a screen saver, whichever way the user wants, without needing to open a browser to check the site to see if new photos have been downloaded.
  • The family members could also subscribe to other people's photo blogs, and see all of the photos from all of their friends and family together.

List Scenarios

There are a number of interesting new scenarios that involve lists of items that are not time-ordered. Looking at the right side of the diagram above, we can see several examples—many of them paralleling similar examples for time-ordered feeds.

One example of the use of a feed might be to allow users to subscribe to wish lists.

  • A daughter in another city creates a wish list on Amazon.com and updates it with new content every few weeks.
  • Her mother wants to know when her daughter wants something new, in case she wants to get it. She also wants quick access to the list, for special occasions.
  • The mother is able to go to the Amazon.com Web site and subscribe to her daughter's wish list.
  • Whenever her daughter adds a new item, she is notified of the addition, and she can tell which one of the items is the new one.
  • When she views the list, she will be able see her daughter's priority order, and she can sort by cost, category, or anything else about the items that Amazon.com makes available for her.

In another case, a user might want to be kept up-to-date with the top-10 singles on a music site.

  • The music site would publish a feed of the top-10 singles using the Simple List Extensions, which enables them to give hints to the client as to how to show the list correctly.
  • The user subscribes to the list, and is able to—at any time—view the ordered list of top-10 singles.
  • Whenever there is a change in the list, he can be notified. The client will be able to show the correct order at all times, and can even give him some filtering controls so that he filters, for example, so that he sees the Rock songs only.
  • If the user chooses to buy a song, links in the item can take him straight to a site where he can purchase it immediately.

Architectural Overview

The RSS support in the Longhorn platform provides a number of useful platform services:

  • The Common RSS Feed List
  • The Common RSS Data Store, with an object model to access it
  • The RSS Platform Sync Engine, which automatically downloads feed content and files (enclosures) from RSS feed

The following architecture diagram shows how the RSS platform elements fit in with applications and publishers.

Figure 2. Architecture overview

The Longhorn RSS Object Model

One of the benefits of the RSS support in the Longhorn Platform is that it enables applications to take advantage of RSS through a rich object model. An application need not ever worry about XML or formats. If, however, the application developers want access to the XML version of the item or feed, it can always retrieve it through the object model.

The following diagram lays out the important pieces of the RSS object model.

Figure 3. RSS object model

The object model mirrors the major components of an RSS feed: Feed, Item, and Enclosure.

The object model is structured around a hierarchical feed list. Developers and users have a choice about whether or not they wish to leverage the hierarchy or simply use it as a flat list.

Objects

Feeds

The top-level object is the Feeds object. It's the entry point into the object model. The Feeds object exposes the root folder for subscriptions.

Folder

Each Folder object contains folder properties, a collection of feeds, and a collection of subfolders along with folder properties.

Feed

The Feed object contains a collection of items as well as feed and channel properties. It is also possible to get at the actual feed XML for applications that want to perform operations on the XML instead of using the feed's properties.

Item

The Item object contains an enclosure as well as item properties. It is also possible to get at the actual item XML for such applications that want to perform operations on the XML instead of using the item's properties.

Most properties of an item cannot be changed by a client application, with the exception of the common read/unread property.

Enclosure

The Enclosure object contains enclosure (or attached file) properties. One of the properties is the local path, which makes it possible for applications to get access to the enclosure via the file system.

Common RSS Feed List

The Common RSS Feed List is exposed primarily through the object model described above.

The feed list also provides an easily accessible copy of the user's feed list as a read-only OPML file under the user's "Documents" folder. The user can use this OPML file to save, e-mail, or import a copy of their feed list into another application.

Common RSS Data Store

Feed content is aggregated in the Common RSS Data store. The store allows for concurrent access by multiple applications. The store is designed to allow efficient updating and access of feeds and individual items.

Enclosure files are written into folders that a user can navigate to from within the Windows Explorer application.

The RSS Common Data Store provides a number of services including automatic purging of feed data and enclosures.

RSS Platform Sync Engine

The RSS sync engine handles on-demand as well as background updates and the merging of new feed content with existing content. Each time a feed is synchronized the feed:

  • Is downloaded from the server via HTTP or HTTPS.
  • Is parsed and normalized into a unified format.
  • Identifies new and updated items.
  • Merges into the store new and updated items.
  • Is updated to reflect the last synchronization time.

New items

New and updated items are identified by comparing each item in a feed with the items for that feed in the store. When an item is new it is then added to the store. When an item has been updated the new version of the item overwrites the one in the store.

New items are always marked as "unread." Updated items similarly get marked as "unread," even if they were "read" before.

Merging for feeds and lists

For feed (time-ordered) content, the content of the downloaded feed is merged with the local content in the following way:

  • New items are appended to the local content.
  • Updated items overwrite the corresponding items in the store.

The merge semantics for lists is somewhat different from the semantics for feeds.

For lists, the downloaded feed is merged in the same way, except that all items in the store that are not in the most recent feed from the server are deleted in the store. Lists also maintain an inherent sorting that is reapplied each time the feed is downloaded. This ensures that the content is resorted even if that is the only change.

Enclosures (files)

Enclosures will be automatically downloaded for feeds that have enclosure download turned on. (By default, all feeds have enclosure download turned off.)

Enclosures of new and updated items will be downloaded in the background during idle network time (except when a user explicitly requests an enclosure download).

Enclosure download is integrated with the Attachment Execute Services (AES), a Windows service that maintains an allow/block list for certain file types. As a result, executable files are blocked by default from being downloaded by the Longhorn platform. Antivirus and antispyware applications can also block enclosures from being downloaded.

Scheduling

Each feed is synchronized in the background on a user-defined schedule so that the user has fresh information available without having to manually check for new content.

Each feed publisher can specify a default update schedule, which the service will respect unless the user indicates otherwise.

How to Enable RSS in Your Application

The RSS object model described above makes it easy for applications to deliver the benefit of RSS to users. The purpose of this section is to provide enough detail to let an application architect imagine how his application can deliver new scenarios by tapping into RSS feeds. We provide two examples:

  • How a photo screen-saver can provide personalized and updated photos by supporting RSS photo-blogs. Every time the screensaver runs, the user sees new photos from people/sites they subscribe to.
  • How a calendaring application can show calendars of games, conferences, school events, and so on by tapping into feeds of calendar events. The users can see their personal calendar side-by-side with these events and coordinate their schedule.

These demos were shown at GnomeDex 5.0 and in the Channel 9 interview. You can view them by going to http://blogs.msdn.com/ie.

Subscribing to photo blogs

Photo blogs, moblogs, and video blogs are a testament to the human desire to create and share photos and videos. In fact, it is easier to create an RSS feed with enclosures than it is to create a good-looking HTML site.

In this example, we'll describe how a screen-saver can use the Longhorn platform support for RSS to add support for updatable feeds of photos to its usual functionality.

After reading this, we hope you see how adding RSS functionality makes any existing application that deals with photos and videos more compelling.

  • The user navigates to a photo blog—this could be the user's space on MSN or a community focused on photos.
    • The site developer should provide an RSS feed with enclosures for each photo.
    • The site developer should ensure that the main Web page refers to the RSS feed via the link HTML element in the header of the Web page. This will allow the browser to inform the user that an RSS feed is available for that page and they have the option to subscribe to it.
  • The user likes the photos and subscribes to the RSS feed. The RSS sync engine downloads the RSS feed and the associated enclosures—in this case, the photo files.
    • The sync engine keeps the content and photos up-to-date.
  • When the screensaver activates, it uses the RSS object model to enumerate the feeds that have photo enclosures.
  • The screensaver cycles through each photo-feed. For each RSS item, it shows the photo in the background and creates a caption by combining the RSS item's title and description.
  • Every day, new photos will be downloaded to the user's machine.
    • The screensaver can use the RSS APIs to construct the list of photos in reverse-chronological order. This ensures that the new photos are shown first.
    • Now, whenever the screen-saver turns on, users will be staying connected with the latest pictures and photos from people and communities they care about.

Subscribing to calendar feeds

Creating a calendar RSS feed is a relatively simple task for publishers. Consuming a calendar feed using the Longhorn support for RSS is also relatively simple. 

This combination presents the opportunity for the application developer to build a great calendaring experience that lets users stay on top of events. 

  • The user navigates to a site with a schedule of events on it. This could be a sports team's game schedule, a school's PTA schedule, or a department's recurring meetings. For this example, we will use the GnomeDex 5.0 conference schedule.  
    • The site developer should create an RSS feed corresponding to the Web page. The RSS feed should refer to iCal files for each event as enclosures in the RSS feed.
  • The user is interested in staying up-to-date with the GnomeDex calendar and subscribes to the RSS feed.
    • The RSS sync engine downloads the RSS feed and the associated enclosures—in this case, the iCal files. 
    • The sync engine regularly goes back to the site and keeps the feed content and enclosures up-to-date on the user's PC.
  • The calendaring application calls the RSS APIs to determine if there are feeds that have calendar files as attachments. 
    • The calendaring application should perform this operation at application launch and register with the platform for notifications (to catch updates while the application is running without needing to poll the platform).
  • By using the RSS APIs, the calendaring application will see that the user has subscribed to a feed for "GnomeDex schedule".
    • The calendaring application can create a new calendar with the name of the feed. Within this calendar, the app should create an event for each iCal file. 
  • The next time the user uses the calendaring app, she will notice that a new calendar has been created and is already populated. She can use the familiar actions of the calendaring app to see this new calendar side-by-side with her personal calendar and drag and drop items into her personal calendar.
  • If there are new events added to the calendar, the RSS feed will get updated and the RSS sync engine will pick up the updates. Using the RSS APIs, the calendaring application will add the new events to the calendar.

Posted using illegal copy of BlogJet.
Please purchase a license here.

Writing Your Applications with Visual Studio .NET on Windows XP Professional

 

Summary: This article discusses the productivity benefits of developing application software on Windows XP using Visual Studio .NET. (9 printed pages)

Windows XP Professional: The Developer Operating System

Are you constantly on the lookout to improve your professional productivity and the productivity of your development organization as a whole? If so, immediately adopting Microsoft® Windows® XP Professional for your application development platform should be very high on your To Do list. Here's why.

Greater Reliability and Performance => Higher Developer Productivity

There are multiple contributing factors to the greatly improved reliability and performance of Windows XP as compared with earlier Microsoft operating systems.

As compared with Windows 98 and Windows NT 4.0

Tired of crashing your desktop when you test your latest changes? If you are developing applications for the Windows 9x platform, you may have concluded that you are stuck on that platform yourself. Think again. Yes, you have to test on all the platforms you support, but Windows XP is one of those platforms!

Therefore, instead of developing on Windows 9x and relegating Windows XP to one of the configurations you test in your lab, why not develop on Windows XP and test Windows 9x in the lab? It's a very good bet that most of the bugs you encounter on Windows 9x will repro on Windows XP, allowing you to spend the great majority of your time in the more productive development environment of Windows XP.

How much more reliable is Windows XP? Last year the National Software Testing Laboratory concluded that Windows 2000 Professional is 13 times more reliable than Windows 98 and three times more reliable than Windows NT® 4.0 Workstation. Read the details at this Microsoft Web site. New reliability tests of Windows XP are underway that are expected to improve on the Windows 2000 foundation.

How much faster is Windows XP? eTesting Labs Inc. found Windows XP to be overall the fastest version of the Windows operating system ever created for a wide range of desktop computing tasks. For example, as explained in this report, average application startup times in Windows XP improved by 25 percent over Windows 98, translating directly into faster build cycles for you.

As compared with Windows 2000

Many of the kernel improvements in Windows XP that address performance and reliability are available to Windows 2000 desktops via Service Pack updates. Similarly, many of these improvements that result from including the latest device drivers are available by downloading and installing the latest drivers from the appropriate PC peripheral manufacturer's Web site.

So, if you are already running Windows 2000 and keeping your system up-to-date, a decision to upgrade to Windows XP predicated primarily on increasing your development platform reliability and performance may be close to a wash.

Still, you might be swayed by all the additional reliability features that have been added to Windows XP.

New reliability features

Windows XP builds on the Windows 2000 foundation by adding a number of new, higher-productivity features aimed squarely at reducing the number of critical problems that occur. These features create faster and easier problem resolution and provide a more reliable personal computing experience.

The article Reliability Improvements in Windows XP Professional discusses the new productivity features added to Windows XP (including links to even more details), such as the Windows Driver Protection feature that protects you from installing and loading defective drivers, as well as the Device Driver Rollback features that represent a huge productivity improvement over the Last Good Known Configuration option in Windows 2000 and Windows NT. This article also reviews the Dynamic Update option in Windows Setup that can automatically pick up the latest Setup updates from the Windows Update site.

Related links:

Fast User Switching

Fast User Switching is a new feature of Windows XP that builds upon the Windows 2000 infrastructure for the separation of user state and data settings. The primary productivity advantage derives from your new ability to test application features on the same computer using multiple, simultaneously logged-on user profiles. To do this without Windows XP requires multiple machines or lots of time-consuming log-off and reboot cycles.

Thus, it is possible to create multiple user profiles with differences running the gamut of language and accessibility settings to different network or local computer resource access privileges.

A variety of programming guidelines that may be applicable to your particular application scenario are discussed in the related links below.

Related links

Isolated Applications and Side-by-Side Assemblies in Windows XP and the .NET Framework

The Windows XP approach to isolated applications and side-by-side assemblies represents a significant advance over the side-by-side sharing and dynamic-link library (DLL) redirection introduced in the Windows 98 Second Edition/Windows 2000 timeframe. These earlier implementations recommended that developers build new components supporting the simultaneous execution of multiple versions of that component. This relied upon using the registry, so components were not fully isolated. In the event of a registry conflict, applications could still be broken.

With Windows XP, the assembly is described by a manifest; the registry is no longer relied upon for storing and accessing the COM activation data. This allows components to now be fully isolated from each other. Shared assemblies can now be serviced as well—unlike statically linking DLLs, the Windows XP configuration enables assembly publishers, application publishers, and administrators to change side-by-side assembly dependencies after deployment. Windows XP provides a model for safely servicing assemblies and managing which side-by-side assemblies an application uses.

These concepts of isolating applications, usage of assemblies, manifests, explicit version management, and servicing with configuration are also fully supported in the .NET framework. Just like the Windows XP implementation, the Common Language Runtime in .NET enforces requests for specific versions by providing a default version, or by honoring publisher overrides per assembly and administrator overrides per system. Also, using services provided by the Common Language Runtime, Visual Studio® .NET automatically creates manifests during code development.

Related links

Stored User Names and Passwords

When you log on to a computer running Windows XP Professional, you supply a user name and password that becomes your default security context for connecting to other computers on networks and over the Internet. However, many users have cases in which they need to use different names and passwords for connecting to different resources. Examples could include:

  • You want to log on to your computer with a standard account but connect to certain computers as an administrator for maintenance and troubleshooting reasons.
  • You work at home and want to use your work user name and password to connect to work-related servers.
  • Your account is in a domain and you need to access computers in an untrusted domain.
  • You want to access Web sites with user names and passwords specific to each of those sites.

You can access the user interface to manage your stored credentials in the Advanced tab on the User Accounts Control Panel applet.

You can read more about this feature by entering "hh key.chm" into the Start | Run dialog.

How many times have you been stuck at work because you needed to complete a long-running operation before you could go home? Or maybe you started the operation hoping it would complete overnight, but now you're worrying about it when you should be focused on being home. Or perhaps you've been stuck in your office working on a project that could only be done on your workplace computer?

How many times have you spent hours reproducing a bug on your own system that was readily reproducible on another machine you didn't have physical access to?

The Remote Desktop Connection feature in Windows XP provides a ready solution to these and innumerable other scenarios in which you need to access another computer remotely and securely over a network connection.

Using Remote Desktop, you can run applications on a remote computer running Windows XP Professional from any other client computer running any Windows operating system. The applications run on the Windows XP Professional–based computer and only the keyboard input, mouse input, and display output data are transmitted over the network to the remote location.

Related links

An overview of Windows XP Remote Desktop.

How to set up and use Remote Desktop.

Tuning Remote Desktop.

Remote Assistance

Remote assistance is similar to the Remote Desktop Connection in the sense that it allows one computer to view or control another computer remotely. However the Remote Assistance user interface is designed for interactive scenarios where users are logged on and sitting in front of both machines at the same time. (In fact, Remote Desktop Connection does not allow a user to be logged onto a remote machine while it is being controlled remotely.)

Imagine e-mailing a new build to your customer or partner and then phoning them to review installing it and the changes and fixes. Now you can vastly improve on this experience if they ask you for Remote Assistance—you can personally walk your partner through the install, showing them the changes while they sit back and watch you drive their computer remotely. Got Web cameras? Even better—now you can see their faces when you show them your favorite feature.

The links below describe several scenarios that can be used to initiate remote assistance, as well as some details for administering remote assistance on a home or corporate network.

Related links

TechNet Step-by-Step Guide to Remote Assistance.

Using Remote Assistance in Windows XP.

Remote Debugging with Visual Studio .NET

How many times have you had to hike to another building, or even fly somewhere, to debug a problem that you could not reproduce on your own machine? What if you could debug the problem on the remote computer without leaving your own desktop?

If you have the Visual Studio 6.0 remote debugging feature working, then you already know how incredibly your productivity is boosted by source-code debugging your application components running on a server in the next building.

Unfortunately, you might also know how the remote debugging feature was very temperamental, to put it nicely, in Visual Studio 6.0. Not so with Visual Studio .NET; there are still some steps you must take to set it up, but not nearly as many hoops to jump through as before. And even better, after you get it working, it stays working.

Related links

Get the Visual Studio .NET Release Candidate.

Learn more about remote debugging with the Visual Studio .NET "What's New in the Visual Studio Debugger" documentation topic available with the Visual Studio .NET Release Candidate above.

Real-time Communications (RTC)

Windows XP includes a new set of interactive features for communicating with friends and colleagues in real-time using Windows Messenger. These features enable new scenarios for collaborating with your colleagues and partners in the office or the next city directly from your desktop or laptop computer, including text messaging, voice-only and video conferencing, interactively transferring files, sharing applications or drawings, or remotely assisting a friend or colleague by taking over their entire desktop by invitation.

The plumbing for these collaboration features is also available for use by developers in their own applications. Much as reusing the WebBrowser control enables developers to easily add browsing, document viewing, and data downloading capabilities to their applications, the new RTC API in Windows XP allows developers to easily integrate the real-time communication features of Windows XP into their application.

In addition to integrating communications features based on PC-to-PC sessions as seen in Windows Messenger, the RTC client application programming interface (API) enables PC-to-phone and phone-to-phone calls.

Related links

Developing for Windows XP with Visual Studio .NET

Visual Studio .NET provides a complete set of tools for building Windows XP applications. The tools are based on a new multi-language paradigm in which any programming language can execute under the control of a common language runtime with equal access to the same integrated development environment features and a single, unified class library. Application code that executes on the common language runtime is called managed code.

The class library, provided by the .NET Framework, is a framework of object-oriented, hierarchical, and extensible APIs that unify previously disparate models for application development such as the Microsoft Foundation Classes for C++ and the Windows Foundation Classes for Java, as well as the traditional COM+ and Win32 programming models.

Visual Studio .NET, together with the .NET Framework class library and common language runtime, include functionality for creating Windows applications, Web applications, and Windows Service applications. They also provide functionality for accessing traditional COM interfaces and DLL functions from managed code, and vice versa.

The rest of this article discusses accessing Windows XP functionality from managed code.

Related links

Accessing COM Components from Visual Studio .NET

To simplify the development of applications that need to interact with either your own COM+ components or those provided by Microsoft or third parties, the common language runtime offers a set of features that conceal differences between the managed and unmanaged programming models, such as calling conventions and error handling. Visual Studio .NET uses these features to provide the ability to write managed code that accesses functionality implemented by COM DLLs as if the COM interfaces were written in managed code. That's because when you add a reference to a COM type library in Visual Studio .NET, managed wrappers are generated for the COM interfaces described in the type library. Of course, this means there is a bit of a performance penalty accessing COM functionality from managed code.

Related links

Expose a COM+ Application as an XML Web Service

Using Windows XP and the .NET Framework you can easily expose existing COM+ applications as SOAP endpoints. Thus the methods on a COM interface can be turned into a Web service by clicking a checkbox exposed on the Activation tab in the COM+ Application properties dialog box in the Component Services console.

To learn more, check out this MSDN technical article and sample code: Microsoft .NET and Windows XP COM+ Integration with SOAP.

Use an RTC control on a Windows Form

It is pretty easy to access the RTC capabilities of Windows XP from managed code in Visual Studio .NET by adding a reference to the type library (as discussed above).

However, a bit more work is involved to make RTC as easy to program on a Windows Form at design-time as, say, a textbox, or other control in the Visual Studio .NET Toolbox. So we are providing you with a managed wrapper for RTC for use in Visual Studio .NET Release Candidate in order for you to immediately start playing with integrating RTC into your Windows Forms-based applications.

This initial release of the RTC managed wrapper does not include support for the Presence functionality for determining online availability and location information. We encourage you to play with the RTCSimple form included in the download and to send suggestions and bugs to msdn@microsoft.com with a subject line of "Issues for RTC Managed Wrapper." The sample will be updated with the best of your suggestions and with the presence functionality (after Windows .NET Server Beta 3—required to store the presence information—is released).

Download the Real-time Communications COM Wrapper.

Related links

Using Background Intelligent Transfer Service in Visual Studio .NET

Got a large data file you'd like to download in the background during spare CPU cycles and network bandwidth? Background Intelligent Transfer Service (BITS) is the plumbing that Windows Update uses to transfer files asynchronously to Windows XP desktops, and it is available for any client application needing to get data files from an HTTP server.

BITS continues the download after the initiating application exits, as long as the user remains logged on and maintains a network connection. If the user does log off or interrupts the network connection, BITS will automatically suspend the transfer and resume it the next time the user logs on and establishes a network connection. The transfer state will also persist across machine reboots. BITS exposes a queue manager with the ability to prioritize transfers among four levels of foreground and background priority, and supports polling and callbacks for transfer job status.

The Platform SDK includes a C++ sample showing how to access this functionality. You can download and install the Platform SDK here (make sure you check the box to download the samples), after which you will find the sample in \Program Files\Microsoft SDK\Samples\Web\bits\bits_ie folder on the installation drive.

If you would like to use the BITS interfaces from managed code in Visual Studio .NET, see Using Windows XP Background Intelligent Transfer Service with Visual Studio .NET. This article explains in detail how to use BITS with Visual Studio .NET through a managed wrapper sample code that is included with the MSDN Download.

Bdadotnet_Beta2.msi.

Posted using illegal copy of BlogJet.
Please purchase a license here.

Posted using illegal copy of BlogJet.
Please purchase a license here.

Background Intelligent Transfer Service (BITS)

Summary: This article explains how to use Microsoft Background Intelligent Transfer Service (BITS) in Microsoft Visual Studio .NET through a wrapper around API calls. The code included with the download requires Visual Studio .NET and Microsoft Windows XP. (9 printed pages)

 

Contents

Introduction
Customized APIs
Using the BITS Wrapper
Items Included in Download
Conclusion

Introduction

One of the realities of the Internet is that it can take a while to download files of any significant size. Another reality is that no one wants to wait while these downloads occur, which has lead to a problem with applications that update themselves over the Internet: users choose not to download the latest patches, because it would force them to wait while the new files and application components are downloaded. In time, this problem can lead to users ending up far behind the latest version of their software.

What is needed is some way to download fixes and updates without impacting the user experience in any way. Well, that is just what Windows Update does in Microsoft® Windows® XP. Windows Update can be configured to download the latest software patches automatically (and it can be configured not to, an essential feature to give users control), and it does so without impacting the user's experience by performing these downloads in the background.

Figure 1. Windows XP Automatic Updates Feature

When I see a great new feature like this in Windows, the first thing I think is "how can I implement this in my own applications?" In this case, an answer is readily available. It turns out that the technology used by Automatic Updates is a feature called Background Intelligent Transfer Service (BITS). BITS is exposed to programmers through a set of APIs.

Customized APIs

The APIs and the associated examples are aimed at Microsoft Visual C++® programmers, so there was a little bit of work required to make them accessible to .NET languages.

Using the tools included with Microsoft Visual Studio®, a type library was generated from the Bits.idl file that is included with the Platform SDK. The Bits.idl type library was then converted into a .NET assembly by the type–library import (tlbimp) utility. For more information see Using the MIDL Compiler, and Type Library Importer.

Once the assembly was generated by tlbimp, a project could reference it just like any other .NET assembly. At this point, the features of BITS are useable and exposed using the interfaces documented in the Platform SDK. However, like many sets of APIs, BITS is not exposed in the programmer-friendly way that .NET developers are accustomed to, so I decided to write another layer, called a wrapper, on top of the BITS library, making it easier to use from .NET.

Note   You are working with a customized wrapper developed specifically for this article, instead of directly against the BITS libraries. The section in the Platform SDK discussing BITS is your best source of information for understanding exactly how to use this technology.

Using the BITS Wrapper

The balance of this article discusses how to use the wrapper to work with BITS and do the following:

  • Create a transfer job.
  • Receive notification of changes to your job(s) status.
  • Directly cancel, suspend, and complete a job.

This article is based on BITS library version 1.0. BITS library version 1.5 and later will include additional functionality that is not covered in this article.

This section discusses:

Getting Started
Creating a New Job
Adding Files to a Job
Checking the Job Status
Using Events

Getting Started

Before you can use any of the transfer service functionality, you need to reference the wrapper. Once the reference to the wrapper is added, and you have added an Imports Microsoft.Msdn.Samples.BITS statement to the top of your code, you can create an instance of the Manager object, which wraps the BackgroundCopyManager object in the underlying library. The constructor for the Manager class does not have any arguments, so creating a new instance is straightforward.

Dim myBITS As New Manager()

The Manager object is the core of any work you do with BITS:

  • Manager enables you to create new jobs.
  • With Manager, you can obtain a collection of jobs currently in the system.
  • You can retrieve a specific job using the Manager identifier.

Creating a New Job

Manager object exposes the CreateJob method, which creates a new transfer job when given a job name, with two other overloaded versions. You have the option of additionally specifying a description, or a description and two configuration values (the retry delay and the retry timeout). In its most simple form, you can create a new job by specifying only the name.

Dim myNewJob As Job = myBITS.CreateJob("Test Job Name")
Note   There is no requirement for the name of the job to be unique, it is used only for your reference, and a GUID is created to be the real unique identifier for a particular job. This identifying GUID is available through the ID property of the Job class.

Adding Files to a Job

Although the API for BITS supports adding one file or an entire group of files to a job with a single method call, the wrapper in this download only provides the ability to add a single file request at a time. For each file you add, you will need to specify the local destination and remote source file name.

myNewJob.AddFile("c:\msdnlogo.gif", _   "http://www.coldrooster.com/msdn.gif")

The directory specified for the local path must exist, and the account that creates this job must have permission to create files in it. If the local file already exists, it is replaced with the newly downloaded file once the job is completed.

NOTE   An error occurs if the local file cannot be replaced because it is read–only, or the job owner does not have permission to delete it once the job is completed. The remote file must also exist, and be static. Dynamic content such as ASP or CGI cannot be downloaded using this technology because BITS uses the Range request header to restart file downloads, which only supports static content. For more information on the Range request header, see section 14.3.5 of the HTTP 1.1 specification (RFC2616.txt).

Checking the Job Status

A new job starts in a suspended state, which is good because the job itself is not very useful until you have added the appropriate files. You must force the job to resume before any actual transfers will occur.

myNewJob.ResumeJob()

Resuming a job without any files will cause an error, as will trying to resume a job that is already completed or cancelled. Jobs automatically suspend when the user that owns the job is not logged on. You can also suspend the job using the Suspend method.

Note   Jobs only run when the account that created them is logged on. If a job is created by an application running in the Local System context (such as a Windows Service) then it will run at all times, even if no one is logged on.

Once a job has completed transferring file(s) down to the local machine, those files are not available to the user until the job is acknowledged through a call to the Complete method. You can use the State property to determine the current status of a job, as shown in this code:

If currentJob.State = JobState.Transferred Then    currentJob.Complete()End If

The possible states, and what each state indicates, are documented as part of the BITS reference material.

Regardless of the specific status, you obtain the current progress of a job through the Progress property, which returns the bytes transferred/bytes total and files transferred/files total values, enabling you to determine a percentage of work that has been done.

Ideally, to implement all concepts discussed so far in this article, set up a BITS job that transfers an extremely large file and will not expire before you have implemented the concepts in a test environment. One particularly large file, perfect for trying a long-running BITS transfer and available on the web for downloading, is the Windows 2000 SP2 install file.

The following code:

  1. Creates an instance of the Manager object.
  2. Creates a new job.
  3. Then adds the SP2 install file to the new job and starts the job with ResumeJob.

A loop, through all of the jobs that are currently queued for the user, displays the current progress and status of each job. The user should now have an option to continue the loop or stop the loop. Once the user declines to continue the loop, the transfer job for the SP2 executable is cancelled, and the temporary file created for this file transfer is deleted.

Imports Microsoft.Msdn.Samples.BITSModule Module1    Sub Main()        Dim myBITS As New BITS.Manager()        Dim sp2Job As Job = myBITS.CreateJob("SP2 Job")        sp2Job.AddFile("c:\bigfile.exe", _         "http://download.microsoft.com/download/.../W2KSP2.exe")        'Note that this is not the complete URL,        'the full URL to any large file will do        sp2Job.ResumeJob()        Dim Jobs As BITS.JobList        Dim currentJob As BITS.Job        Dim currentProgress As BITS.JobProgress        Dim exitLoop As Boolean = False        Jobs = myBITS.GetListofJobs()        Do            For Each currentJob In Jobs                currentProgress = currentJob.Progress()                Console.WriteLine("{0} {1}/{2} ({3})", _                    currentJob.DisplayName, _                    currentProgress.BytesTransferred, _                    currentProgress.BytesTotal, _                    currentJob.StateString)            Next            Console.Write("Continue (Y/N)?")            If Console.ReadLine() = "N" Then                exitLoop = True                sp2Job.Cancel()                Console.WriteLine("Job Cancelled")            End If        Loop Until exitLoop = True        Console.ReadLine()    End SubEnd Module

Every complete loop should produce console output like this example:

SP2 Job 2627516/106278016 (Transferring)Continue (Y/N)?

If you decide not to continue, the loop will stop and the job will be cancelled.

If your job is in the transferring state and you remove your network connection by disconnecting a dial-up connection, disabling a LAN connection, or removing your network cable from your network card, the job should enter transient error mode, indicating that it has encountered a network problem. Once network connectivity is restored it will resume in the transferring state.

The amount of time before BITS tries to resume a transfer after a transient error occurs is controlled by the MinimumRetryDelay property of the Job object. The length of time after which BITS will not continue to retry, if transferring does not resume, is controlled by the NoProgressTimeout property. These timing values default to ten minutes and fourteen days respectively. At least ten minutes will expire after you disconnect from the network before the transfer will attempt to resume.

Using Events

The previous example showed you how to poll for the current status of a job. However, BITS also has a notification–based system. Through the .NET wrapper, the notification-based system is exposed as the JobEvents class where you add any number of jobs that you wish to monitor. Events are raised when a monitored job encounters an error, is modified (including status changes), or finishes transferring. The next code sample shows how this notification interface is used behind a Form to react to events occurring with any of the current jobs.

Form code that is not directly related to the BITS example has been omitted. See the downloadable code for the complete version.

Note   By default, the wrapper does not register for the JobModification event since it is called often and expensive. If you wish to register for this event, you must use the overloaded version of JobEvents.AddJob and specify the desired events yourself. In any event handler, you should be careful to not do too much work, since you are blocking the thread that raised the event. If you have a lot of unfinished work in response to a raised event, you should spin off a new thread to handle it.
Imports Microsoft.Msdn.Samples.BITSPublic Class Form1    Inherits System.Windows.Forms.Form    Dim WithEvents myEvents As New JobEvents()    Dim myJobs As JobList    Private Sub Form1_Load(ByVal sender As System.Object, _                           ByVal e As System.EventArgs) _                           Handles MyBase.Load        Dim myBITS As New BITS.Manager()        myJobs = myBITS.GetListofJobs(JobType.CurrentUser)        Dim currentJob As Job        For Each currentJob In myJobs            myEvents.AddJob(currentJob)        Next        ListBox1.DataSource = myJobs    End Sub    Private Sub myEvents_JobModification(ByVal sender As Object, _                                         ByVal e As JobEventArgs) _                                         Handles myEvents.JobModification        Dim sb As New System.Text.StringBuilder()        sb.AppendFormat("{0} ({1})", _                e.JobName, _                e.Job.StateString)        sb.Append(Environment.NewLine)        sb.Append(TextBox1.Text)        TextBox1.Text = sb.ToString    End Sub    Private Sub myEvents_JobError(ByVal sender As Object, _                                  ByVal e As BITS.JobErrorEventArgs) _                                  Handles myEvents.JobError        Dim sb As New System.Text.StringBuilder()        sb.AppendFormat("{0} ({1})", _                e.JobName, _                e.GetErrorDescription())        sb.Append(Environment.NewLine)        sb.Append(TextBox1.Text)        TextBox1.Text = sb.ToString    End Sub    Private Sub myEvents_JobTransferred(ByVal sender As Object, _                                        ByVal e As BITS.JobEventArgs) _                                        Handles myEvents.JobTransferred        Dim sb As New System.Text.StringBuilder()        sb.AppendFormat("{0} ({1})", _                e.JobName, _                "Transferred")        sb.Append(Environment.NewLine)        sb.Append(TextBox1.Text)        TextBox1.Text = sb.ToString    End SubEnd Class

BITS runs in the background, so your programs can start jobs and then periodically check status, instead of having to run throughout the entire download. Remember that BITS is using the user's network connection (although it has minimal impact) and storing files onto their computer, so it is essential that if you use this technology you provide the user with the option of turning it off completely or agreeing to each download before it occurs, just like Windows XP does with the Automatic Updates feature.

Included in Download

In addition to the source for the samples used in this article, the download also includes these required items:

  • The .NET assembly (BackgroundCopyManager.dll) created by importing the BITS type library, and the type library BITS.tlb that was created from BITS.idl.
  • The SIDUtilities project (and compiled assembly), a Microsoft Visual Basic® .NET library used to convert a Security ID (SID) into the string representation of a user's account name. This item is required by the wrapper project.
  • The wrapper for the BITS library, Microsoft.Msdn.Samples.BITS.dll, ready for you to reference in your applications. The code for this wrapper, written in Visual Basic .NET, is also included in the download. If you use Microsoft C#, or any other .NET language other than Visual Basic .NET, you only need to reference the assembly.

The BITS library includes much more functionality than what is covered in this article and most of that functionality is included in the .NET wrapper. For more information, see the section in the Platform SDK that discusses BITS.     WrappingBITS.msi.                                                 

           

Posted using illegal copy of BlogJet.
Please purchase a license here.