Silverlight + SharePoint 2010 - package XAP file in a sandbox WSP Solution

This is a long series of blog posts on developing, debugging and deploying Silverlight and SharePoint solutions.

/blog/2010/6/18/develop-and-deploy-silverlight-sharepoint-2010-solutions.html
/blog/2010/6/22/develop-and-deploy-silverlight-sharepoint-2010-solutions-par.html
/blog/2010/6/28/develop-and-deploy-silverlight-sharepoint-2010-solutions-par.html
/blog/2010/10/18/silverlight-sharepoint-2010-did-you-just-deploy-customizatio.html

 

Assuming by this point, you have built a XAP file from a Silverlight project, and can deploy it manually to SharePoint by uploading to a SharePoint document library and link up Microsoft's Silverlight web part to "play" your XAP file.

Now let's see how we can build a WSP package.

Create a SharePoint Project in your solution

 

clip_image002

Figure: Add a new Empty SharePoint Project

 

clip_image002[5]\

Figure: Provide a debug site, and choose Sandboxed solution

 

clip_image002[7]

Figure: Add a module to this project - you should give it a good name

 

clip_image002[9]

Figure: Select Properties of this module…

 

The following is very special.  If you blink you will miss this!

 

From the Module's properties, find Project Output References and open this dialog.
Then from the dialog

  • select "ElementFile" for deployment type
  • select the project output of your Silverlight project

This step ensures that the Silverlight project output (XAP file), is automatically included as an element file in your SharePoint module. 

Magical!  But very well hidden UI.  Most people don't know it's there!

clip_image002[11]

Figure: Add the Project Output to this module.

 

Open up the module.xml file and check:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Module1">
    <File Path="Module1\SLSPConf.xap" Url="Style Library/SLSPConf.xap" />
  </Module>
</Elements>

I set the destination URL to be Style Library.  You can put it elsewhere but you'll need somewhere where people can actually have read-access.

 

Deploy to Solution Gallery

 

clip_image002[13]
Figure: Deploy the Silverlight solution to Solutions Gallery - you can activate the sandbox solution here.

 

clip_image002[15]

Figure: Activate the site feature

 

VS.NET debugging tip

 

Go to the properties for the SharePoint project.  Select the SharePoint tab, and scroll right down.

  • Tick "Enable Silverlight debugging"
  • Untick "Auto-retract after debugging" - this one makes VS.NET deploy and activate when F5.  But as soon as you stop debugging VS.NET will retract the solution - so your Silverlight stops working!

 

clip_image002[17]

Figure: VS.NET SharePoint project settings.

InfoPath - external data from SharePoint List error

I had this error "The operation could not be completed" when trying to connect to a SharePoint List as an external data connection in InfoPath today.

Show Details just says "Unable to connect to the SharePoint site."

image

Figure: The message box really doesn't tell you anything.

Turned out, I was testing with a new managed path on http://server/sites/TravelFunds/  But the web application did not have a site at the root path.  So the quick fix was to create a new team site (blank site might work too) at the root path http://server/ and then come back to InfoPath, and http://server/sites/TravelFunds/ will now work as expected.

 

This was one of many posts that I read regarding similar problems, and the one that actually applied to me.  http://vspug.com/ssa/2010/03/15/infopath-2010-cannot-connect-to-sharepoint-2010/

SharePoint: automatically sign in with my Windows User Account in IE and FireFox

 

Microsoft's Internet Explorer has a concept of security zones.  It can guess which servers that you are visiting belongs to the corporate Intranet, and automatically pass in Windows Authentication tokens.

Internet Explorer

These options are under Internet Options

image

Figure: Set up Internet Explorer to automatically detect Intranet Sites

image

Figure: Default setting for "Automatic logon only in Intranet zone"

 

FireFox

You can also do this in FireFox, via a slightly different method.

First, about:config

image

Figure: Make a promise to be careful

image

Figure: type NTLM, and find the trusted URIs setting

image

Figure: Double-click and enter your SharePoint server URI, e.g. Intranet.ssw.com.au

image

Figure: Automatic Windows Authentication sign-in in FireFox

(This tip is of course, Windows-only).

Write blogs with Windows Live Writer, and schedule publish to look like a PRO!

A blog post a day keeps writer's block away.

I sat down to write a bunch of blog posts tonight, but instead of having everything published at once, I decided to pace it out and have it publish over a few days. Because really, nobody want to read 5 blog posts all at once!

Here's the hot tip with Windows Live Writer.

  1. Write your blog
  2. Before clicking publish - set a publish date
    clip_image001
    Figure: Set a future publish date
  3. Then hit the publish button
    clip_image002
    Figure: Publish!
  4. See the articles queued for publishing
    clip_image003
    Figure: This guy writes a blog every day!

PowerPoint is for code too

This is a follow up post to Outlook (and blogs) are for code, from my colleague Peter Gfader.

 

I have this problem with PowerPoint

  1. I paste code into the slides for the demo
  2. During the session I copy that code
  3. Paste into VS
  4. BUILD ERROR – funny quotes all over the place
  5. NASTY!

THANKS to this tip, I changed in PowerPoint as well

clip_image002

 

We do so much code presentations, this is a fantastic follow up tip.