Join LiveSide!
Sign In using: Name/Password OpenID
or Live ID: Sign In Live ID
0 out of 8,034 members
are online, & 18 guest(s).

Recent Comments

–ScottIsAFool
re: A “Quick And Dirty” Live Mesh Silverlight Application

–Anheledir
re: A “Quick And Dirty” Live Mesh Silverlight Application

–ScottIsAFool
re: A “Quick And Dirty” Live Mesh Silverlight Application

Log in or Join to leave a comment!

LiveSide on Mobile

Our latest posts and our favorite links,
all on your phone or mobile device
Visit m.LiveSide.net
Or go to www.LiveSide.net
on your mobile device and we'll redirect you!

Tweets We Like

Loading...

LiveSide Time

Redmond

Dallas (server)

London

Shanghai

Windows Live Calendar

PDC LA Nov 17-19

   www.microsoftpdc.com

Follow us on Facebook

    LiveSide.net
   
    Promote Your Page Too

  • LiveSide on the Windows Live Network
  • LiveSide on Facebook
  • LiveSide on Twitter
  • LiveSide RSS  
  • Windows Live Alerts
  •  
  • feedburner
  •  
LiveSide - Developer Blog

A “Quick And Dirty” Live Mesh Silverlight Application

After the LiveFX application I showed yesterday, I will now do the same but for a Silverlight Mesh App, so this would actually appear in your Live Desktop. Like yesterday’s tutorial, this is only really for those who have been given access to the LiveFX and Mesh SDK ‘bits’ at the moment, but when it does eventually go live for all developers, then you’ll be able to use the same tutorial.

Again, I will make the assumption you have all the SDK bits installed. Now, first off you need to create a Mesh-enabled project on the Azure Services Developer Portal. Then create a new Mesh Silverlight project in Visual Studio 2008:

LiveSideMeshAppCreationPage

In the solution you have a manifest.xml file, this holds some of the details for the project; this will get uploaded with your project. In this instance, mine looks like this:

<Manifest xmlns="http://schemas.mesh.com/application/manifest/2008">
  <Name>LiveSideMeshApp</Name>
  <Description>Live Framework Silverlight Mesh-enabled Web Application</Description>
  <PublisherName>LiveSide.net</PublisherName>
  <DisplayVersion>1.0</DisplayVersion>
  <MultiInstance>false</MultiInstance>
  <PrivacyPolicyLink>http://LiveSide.net</PrivacyPolicyLink>
  <SupportLink>http://LiveSide.net</SupportLink>
  <VendorLink>http://LiveSide.net</VendorLink>
  <RequireDelegation>false</RequireDelegation>
</Manifest>

For this Mesh App, all I will be doing is a simple Silverlight application that simply has a TextBlock and we will use the LiveFX to just insert some details into that TextBlock (the same details I used for the Console app).

LiveSideSilverlightMeshDesign

Now, the code; in the console app, you will remember that we had to call loe.Connect() and provide some credentials, however, with an actual Mesh app, this isn’t required as that is all done automatically, so we can go ahead and just code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.LiveFX.Client;
using Microsoft.LiveFX.ResourceModel;

namespace LiveSideMeshAppSilverlight
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();

            MeshApplicationService meshApp = Application.Current.GetMeshApplicationService();
            // once mesh contents are loaded we get callback
            meshApp.LoadCompleted += new EventHandler(meshAppLoaded);
            meshApp.Load();
            // Create a new instance of the LOE referencing what we get 
            // given from the Mesh Service. Note that we do not need to call
            // loe.Connect() as it is already connected.
            LiveOperatingEnvironment loe = meshApp.LiveOperatingEnvironment;
            
            // This gets the Messenger PSM
            //Profile prof = loe.Profiles.Entries.Single(e => e.Resource.Title == "GeneralProfile");
            //var somethingelse = (GeneralProfile)prof.Resource.ProfileInfo;
            
            // Start writing the string to put in the TextBlock
            string text = string.Empty;
            text += "Details for " + loe.Mesh.ProvisionedUser.Name + "\n";
            text += "Email Address: " + loe.Mesh.ProvisionedUser.Email + "\n";
            //text += "Messenger PSM: " + somethingelse.PersonalStatusMessage + "\n";
            text += "Number of contacts: " + loe.Contacts.Entries.Count() + ".";

            // Set the TextBlock text
            MyTextBlock.Text = text;
        }

(One thing to note about this code, I have had to comment out the bit of code that gets the Messenger PSM, this is due to a bug that has been found in the LiveFX Silverlight library. Once this has been fixed, you could uncomment out that section.)

Now that we have the code in, we can then send it to the Mesh. The first time you do this for an application, you will need to follow a process. To start off with, you will need to sign in with your Windows Live ID, this should be your ID that has been provisioned for the Mesh developer CTP.

Next you need to upload the application package, so in your project page, click on the upload package button:

UploadPackageMesh

To get the location of the package, there is a nice link to click in Visual Studio:

ApplicationUploadSelfLink

This window comes up automatically. Once you have uploaded the application package you need to get the newly created Application Self Link, which can be found on the project page, and just put that into section 3 of the above window. Your project will then upload to the cloud:

ProjectUploadingMesh[4]

A new browser window will then open and take you to your developer sandbox of the Live Desktop and preload your new application

LiveSideMeshAppInBrowser[6]

And there you have it, your first Mesh App. Unfortunately, due to another bug, you can’t view your home made Mesh Apps on your desktop yet, as it signs you out of the Mesh Client as soon as you load it.

SL

Comments

ScottIsAFool wrote re: A “Quick And Dirty” Live Mesh Silverlight Application
on Tue, Nov 18 2008 4:43 AM

Not sure what's going on with the last image there folks, something seems to be screwy. Looks fine in Writer and in the CS online editor, so you'll have to forgive the oddness.

Anheledir wrote re: A “Quick And Dirty” Live Mesh Silverlight Application
on Tue, Nov 18 2008 5:07 AM

It seems to be a problem with a plugin - some chars are replaced with the Devil-Smiley in your alt-Tag of the image. I assume this is done on-the-fly when viewing the post, so you cannot see this error in Live Writer or in your CS online editor.

Removing those smiley-enabled chars from your alt-tag should solve the problem. :-)

ScottIsAFool wrote re: A “Quick And Dirty” Live Mesh Silverlight Application
on Tue, Nov 18 2008 5:31 AM

Ok, we [sunshine and myself] found it. there was a CS setting for it. Turned that off and all is well with the world again.

Sign In Live ID using Live ID, Name/Password, or OpenID
or Join LiveSide to leave a comment!