Andrew Connell [MVP SharePoint]
1741 Posts |  46 Articles |  5310 Comments
.NET  |  MCMS  |  SharePoint  |  Office System
Andrew Connell's RSS Feed    
AC's Blog Quick Links
SharePoint Quick Links
Article Categories
Archives
May, 2012 (3)
April, 2012 (4)
March, 2012 (4)
February, 2012 (4)
January, 2012 (12)
December, 2011 (6)
November, 2011 (3)
October, 2011 (17)
September, 2011 (8)
August, 2011 (6)
July, 2011 (7)
June, 2011 (13)
May, 2011 (9)
April, 2011 (15)
March, 2011 (1)
February, 2011 (6)
January, 2011 (5)
December, 2010 (11)
November, 2010 (6)
October, 2010 (12)
September, 2010 (5)
August, 2010 (4)
July, 2010 (5)
June, 2010 (6)
May, 2010 (11)
April, 2010 (11)
March, 2010 (9)
February, 2010 (9)
January, 2010 (3)
December, 2009 (10)
November, 2009 (15)
October, 2009 (15)
September, 2009 (7)
August, 2009 (4)
July, 2009 (10)
June, 2009 (8)
May, 2009 (2)
April, 2009 (9)
March, 2009 (6)
February, 2009 (16)
January, 2009 (6)
December, 2008 (12)
November, 2008 (12)
October, 2008 (27)
September, 2008 (13)
August, 2008 (14)
July, 2008 (14)
June, 2008 (12)
May, 2008 (23)
April, 2008 (12)
March, 2008 (15)
February, 2008 (13)
January, 2008 (12)
December, 2007 (10)
November, 2007 (8)
October, 2007 (15)
September, 2007 (20)
August, 2007 (21)
July, 2007 (16)
June, 2007 (8)
May, 2007 (25)
April, 2007 (16)
March, 2007 (18)
February, 2007 (18)
January, 2007 (12)
December, 2006 (16)
November, 2006 (13)
October, 2006 (18)
September, 2006 (22)
August, 2006 (27)
July, 2006 (23)
June, 2006 (23)
May, 2006 (23)
April, 2006 (9)
March, 2006 (17)
February, 2006 (15)
January, 2006 (23)
December, 2005 (31)
November, 2005 (32)
October, 2005 (38)
September, 2005 (53)
August, 2005 (30)
July, 2005 (63)
June, 2005 (30)
May, 2005 (59)
April, 2005 (29)
March, 2005 (74)
February, 2005 (27)
January, 2005 (22)
December, 2004 (32)
November, 2004 (42)
October, 2004 (39)
September, 2004 (20)
August, 2004 (14)
July, 2004 (27)
June, 2004 (40)
May, 2004 (5)
April, 2004 (6)
March, 2004 (16)
February, 2004 (26)
January, 2004 (23)
December, 2003 (7)
November, 2003 (14)
October, 2003 (20)
September, 2003 (4)
Post Categories



Managed Windows Shared Hosting

This past week I did a session on creating RIA applications in SharePoint at SharePoint Connections in Las Vegas, you know… applications with rounded corners. :) When creating RIA apps for SharePoint, you will eventually come to a fork in the road with a sign that says “how would you like to deploy this?” As usual, the answer is “it depends” but they all boil down to the same final result: the XAP must be in an accessible location.

If the Silverlight application is going to be used across the farm, as in the case of the OOTB site/list/library creation application, it should be deployed to the _layouts directory as you only need one instance on the server. However when building an application that’s going to be used by a single SharePoint site (such as a product browser), I like to create a new library called “Application Gallery” that’s parallel to other system galleries like the Master Page Gallery, Web Part Gallery, Solution Gallery, etc. I then provision the XAP into this library.

One small thing I showed in my session was how to take the output of a Silverlight project (the *.XAP) and automatically include it in your project to provision it into the target site. Most people hadn’t seen this technique and since we were a bit tight on time, I promised them a blog post. So here it goes…

Scenario: You’ve created a new VS2010 solution with a Silverlight project in it (maybe you did/didn’t create the associated Web project for testing… doesn’t matter regardless. Now, I added a new SharePoint 2010 Empty Project to my solution. Next comes the magic…

Add a new Empty SharePoint Project to the solution. To provision a file, you need to use a Module SharePoint Project Item (SPI) template, so add one of these to the project. The next part is where the magic comes into play as it isn’t very obvious. Select the new Module SPI and view it’s properties (press [F4] if the Properties tool window isn’t visible):

Notice the option Project Output References. This will let us include the output of another project in this project’s SPI! Very slick… click the builder button […] to open the dialog. This lets you include the output from another project into this project. Go ahead and add the Silverlight project and select the Deployment Type=ElementFile in the Feature.

All that’s left is to go into the element manifest (elements.xml) in the Module SPI and modify the <File /> element’s URL attribute to provision the file into the desired location.

The tricky part to this is that by simply looking at the project structure in the Solution Explorer tool window in Visual Studio 2010, you can’t tell anything has been included in he project.

posted on Friday, November 05, 2010 5:28 PM

Feedback

# re: Including the *.XAP Generated by One Project in a SharePoint 2010 Project 12/2/2010 7:29 AM İbrahim KIVANÇ
Gravatar I'm a silverlight developer and I’m new to sharepoint development so I worried about i did something wrong.

So I logged in with NTLM authenticated domain user as default credential on my sharepoint site collection. Also anonymous access is not enabled.

When I called ClientContext in my Silverlight application, I couldn’t get ClientContext value. I tried to accesing sharepoint on my silverlight application from http://localhost:14300/ port and I couldn’t access even I use ClientContext.Current and deployed it to sharepoint i’m still unable to access to sharepoint.

But it returns always Context.Site and Context.Web are null with some exceptions. I add a screenshot of exceptions.

Thanks.

# re: Including the *.XAP Generated by One Project in a SharePoint 2010 Project 12/2/2010 8:56 AM AC [MVP SharePoint]
Gravatar @Ibrahim - ClientContext.Current will only have something is the SL app was loaded FROM a SharePoint site. Otherwise you need to set the site in the constructor: ClientContext("http://foo");

As for null references for the ClientContext.Site & .Web, that's because you haven't initialized them. You need to call ClientContext.Load & ClientContext.ExecuteQueryAsync.

Just some basics you're missing... check this for a good set of resources & tutorial videos: channel9.msdn.com/.../ClientObjectModel. You should also check the SharePoint SDK as well as this VHT on MSDN: msdn.microsoft.com/en-us/library/gg277498.aspx

# re: Including the *.XAP Generated by One Project in a SharePoint 2010 Project 12/17/2010 10:31 AM Ceej
Gravatar AC - is it possible to use this method to provision the *.XAP into a subfolder of the [SharePointRoot]\TEMPLATE\LAYOUTS\ClientBin folder? I'd like to be able to keep all my Silverlight files together in a common location. I'm thinking not but wanted some expert clarification!

# re: Including the *.XAP Generated by One Project in a SharePoint 2010 Project 12/17/2010 3:22 PM AC [MVP SharePoint]
Gravatar @Ceej - Don't use this... you want to treat it as an application page. Use the mapped folder options in VS2010. Yes, you can do what you want to do, just don't use this technique.

Post Feedback

Title:
Name:
Email:
(email will not be displayed)
Url:
Comments: 
Please add 3 and 4 and type the answer here:    
All Comments Are Filtered & Moderated
Unfortunately comment spammers are just too effecient and are constantly dirtying up blogs with irrelevant and unwanted comments trying to improve their standing on search engines. All comments on this blog are moderated. I do not censor comments, but I don't approve comments with vulger language or those soliciting products. Most of the time comments are approved within a few hours of being submitted with the only exception when I'm traveling.

Why are you asking for my email address?
The only reason I'm asking for your email address, which isn't required to submit a comment, is to provide a gravatar if you've created an account for yourself and associated your email address with a small image. If you have a gravatar created for the email address you submit, it will appear next to your comment. Otherwise nothing will appear.

What is a gravatar?
A gravatar is a "globally recognized avatar." You can get more information about gravatars, as well as create your own for free, at www.gravatar.com. You can also view my gravatar here.


Copyright © 2003 - 2012 Andrew Connell
Creative Commons License 
This work is licensed under a Creative Commons License

 
SharePoint Training
Looking for SharePoint 2010 training for developers, administrators, power users, information workers, end users & web designers? Look no further! My company, Critical Path Training offers the best SharePoint training around! We offer public & private classes both as in-person instructor-loed hands-on classes and online classes. Check out our schedule and course catalog for all the ways we can get you going on your SharePoint path!