Simple clear advice in plain English

Hands on: Mesh takes Silverlight offline

Silverlight plus Live Mesh brings the Microsoft cloud to the desktop

Starting a new project
A new Mesh project does not just live in Visual Studio, it also has to be uploaded to Microsoft’s servers. This involves visiting the Developer Portal website and starting a new Live Framework project there (see screen 3). Once created, the website invites you to upload a package. This does not yet exist, so it is time to fire up Visual Studio, choose File, New Project, and select a Visual Basic, Live Framework, Silverlight Mesh-enabled application.

This wizard creates a Hello World Silverlight application, but when you hit debug you will see a difference. Instead of running it in a web page, Visual Studio displays a dialogue telling you to upload a zip package to the Developer Portal.

Click the shortcut to copy the part to the package, then go to the project page, click Browse to upload a package,paste in the path, and upload it. Refresh the page, and in the Web Site Embedding section you will see a URL called Application Self Link. Copy this URL, which represents the online location of the new app, back into the Visual Studio dialogue and click OK. Visual Studio will now update the online version whenever you debug.

Writing the application
The application is like any other Silverlight app except that it has access to Mesh services. At heart, Mesh data lives in collections of objects usually published as RSS-like Atom feeds. The Live Framework SDK includes .Net libraries that wrap these feeds in convenient .Net classes. However, they are in a standard format, so in principle you can code Mesh apps as Javascript browser apps, or as Java, Actionscript for Flash, or native Windows applications.

This simple to-do list app needs a data feed with text entries. The code-behind file for the Silverlight page declares a global variable representing this feed. In the MeshAppLoaded event, it tries to retrieve a reference to PCWListFeed, and if it fails, it creates it. Here is the code for creating the feed:

Dim meshApp As MeshApplicationService = Application.Current.GetMeshApplicationService()
meshApp.DataFeeds.Add(New DataFeed(‘PCWListFeed’))

Once created, the following code retrieves a reference to the feed using Linq (Language Integrated Query) and stores it in the df global variable:
Dim meshApp As MeshApplicationService = Application.Current.GetMeshApplicationService()
df = (From dataFeed In meshApp.CreateQuery(Of DataFeed)() _
Where dataFeed.Resource.Title = ‘PCWListFeed’ _
Select dataFeed).FirstOrDefault

Reader Comments

   

Add your comment

All fields must be completed. Your email address will not be displayed or used to send marketing messages.

All messages will be checked by moderators before appearing on the site.

See our Privacy Policy for more information.

Related articles

No matching document

Related articles

No matching document

Question & Answer

Q.Why are some of the keys on my keyboard doing strange...

> Read the answer

Q.Is my phone’s Bluetooth any use?

> Read the answer

Q.Can I switch boot drives so that I can work on older...

> Read the answer

Best deals on the web

img

Samsung RV520-A07

£359.98- Buy it now

img

Acer Aspire 5750G (LX.RXP02.019)

£399.99- Buy it now

img

Apple MacBook Pro (MD313B/A)

£904.37- Buy it now

Latest issue & subscription deals

Poll

Are you concerned about viruses that target mobile phones?

Jargon Buster

Computing terms explained in plain English

Restore point

A Windows backup of system files and settings.

Great shopping deals from Computeractive