Dot Net Mafia

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog



Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for Ionic, SharePoint, and Office 365.

Office 365 How to: Build and Deploy a Web Part with SharePoint Online

You know by now that the cloud is hot and Microsoft says “we’re all in”.  That being said, there has never been a better time to push all of those chips forward and  jump on the bandwagon.  It’s time to get some experience with SharePoint Online / Office 365.  I know most people don’t have access to the Office 365 beta yet, but when it opens up, you should sign up for the public beta and start getting familiar with it.  If you haven’t seen SharePoint Online yet, check our my previous article which gives a quick tour of it.  I plan to write more about SharePoint Online in the future, so I figured the best place to start is with an introductory development article on building and deploying a web part.  My past series on building and deploying web parts to 2010 and 2007 are still the most popular articles on  Let’s take what we learned there and see how we deploy web parts to the cloud.

Before we get started, let’s reiterate what we’re working with.  With Office 365, your development scenario involves sandboxed solutions.  As you know, these solutions are deployed to the site collection level and offer a restricted subset of the SharePoint API.  If you are already confortable working with sandboxed solutions, you are in great shape to begin SharePoint Online development.

What does the development environment look like?  Well, you know that SharePoint 2010 VM you already have?  You’re looking at it.  Just like Azure, SharePoint Online development also used the “Over the fence” development methodology.  Meaning, you develop your code locally and then throw it over the fence and hope it works.  This may sound bad, but it’s really not a big deal and the Azure people have been doing it for a while.  AppFabric is close to Azure, but there is always a possibility of differences when you get it in the cloud.  As long as you build a sandboxed solution and don’t make use of unsupported features (i.e.: PerformancePoint, BCS, etc), more than likely your code will work when it gets to the cloud.  There may be things that you can do in a Sandboxed solution in SharePoint 2010 compared to SharePoint Online, but it’s far too early to tell at this point.  To get started developing web parts in the cloud, you pretty much need a copy of SharePoint 2010 (or SharePoint Foundation) installed somewhere locally.  This could be native on your Windows 7 machine or inside a virtual machine.  Wherever it is, you will obviously need Internet access to get your code to the cloud.

To get started developing in the cloud, the first step is to build the web part on your local SharePoint environment.  I won’t go through all the steps here, because most of them are the same from my article on 2010 Web Part Development.  However, I will go through the important steps.  The first step is to create a new Empty SharePoint 2010 Project in Visual Studio 2010.  Specify the URL to a local site on your SharePoint server.  Don’t use the address of your SharePoint Online site.  It won’t work.  When prompted for the solution type, choose Sandboxed Solution.


At this point, you have a regular SharePoint project in Visual Studio.  Add a web part to the project just like you would in SharePoint 2010.  Sticking with the Hello World type example, we put some code like the following in our web part.

using System;

using System.ComponentModel;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using Microsoft.SharePoint;

using Microsoft.SharePoint.WebControls;


namespace SharePointOnlineProject3.HelloCloudWebPart



    public class HelloCloudWebPart : WebPart


        protected override void CreateChildControls()


            Controls.Add(new Label() { Text = "Hello, Cloud!" });




At this point, we can test our code locally on our SharePoint server.  Build and deploy the project and then add your web part to a test page on your site.  Again, if you aren’t familiar with these steps, take a look at my Building and Deploying Web Parts with SharePoint 2010 post. If the code, works you should see a similar page like the one below.


Now, we’re ready to send our web part “to the cloud!”.  How do we do that?  Start by using the Package menu to build a SharePoint package (.wsp file). 


This creates a .wsp file located in the bin folder of the project.  We’ll use this file to deploy our web part to the cloud.  It’s now time to open up a browser and connect to your instance of SharePoint Online.  Once you get there, we deploy a sandboxed solution just like we would on-premises.  Go to Site Settings –> Solutions to view the Solutions Gallery.  Click on the Solutions button in the ribbon, and then click Upload Solution.  Browse to the bin folder of your Visual Studio project and select the file ending in .wsp.  Once it uploads, be sure and click the Activate button. 


Now, you just need to ensure the feature is activated by going to Site Settings –> Site Collection Features.  If it is not activated, click the activate button.


Your web part has now been thrown over the fence and deployed to the cloud!  Test it out by going to any page on the site and adding the web part to the page.  You’ll find your web part in the Custom section by default.  If all goes well, your web part should work here too.


Congratulations, you have now deployed code to the cloud!  It’s really not that hard is it?  Now, you might be wondering if you can debug your solution.  Unfortunately, the answer is no.  If you have an issue, you have to step through it locally on your on-premises SharePoint server.  That’s all there is to getting started with SharePoint Online development.  As you can see it’s very familiar to sandboxed solutions development with your on-premises server.



Tom Resing said:

Good stuff, Corey. I'm glad to see a step by step walkthrough on this before it's generally available. I'm sure we'll be seeing a lot more Sandboxed Development projects after Office365 is released and catches on.


April 7, 2011 4:20 PM

CoreyRoth said:

@Tom Thanks!  Yes, it's time for people to get comfortable with sandboxed solutions if they have been avoiding them. :)

April 7, 2011 4:30 PM

Michael Greth [SharePoint MVP] said:

Office 365 Office 365 How to: Build and Deploy a Web Part with SharePoint Online Office 365 How to: Create

April 18, 2011 8:39 AM

Dmitry Andreev said:

Примерно пару недель назад был сделан анонс Office 365 beta и некоторые счастливчики уже получили приглашение поучаствовать в тестировании. Российским представительством Microsoft по этому поводу даже был выпущен пресс релиз в котором заявлено что Office

May 4, 2011 1:39 AM

???????? ???????????????? Microsoft / ???????????????? ?????????????????????????? ?????? Office 365 | News From Earth said:

Pingback from  ???????? ???????????????? Microsoft / ???????????????? ?????????????????????????? ?????? Office 365 | News From Earth

May 4, 2011 11:11 AM

Thomas Trung Vo said:

Step by step to create a Sandbox Solution WebPart for SharePoint Online (Từng bước cách tạo một SharePoint WebPart sao cho có thể chạy trên SharePoint Online)

May 18, 2011 9:12 PM

The Microsoft MVP Award Program Blog said:

Editor's Note: The following is a guest post by SharePoint Server MVP Corey Roth as part of the MVP Award Program Blog's "MVPs for SharePoint" series. Corey Roth is a solutions architect at Stonebridge specializing in SharePoint solutions in the Oil &

May 31, 2011 5:13 PM

MVPs for SharePoint 2010: Debugging Techniques for SharePoint Online Applications - MSDN Blogs said:

Pingback from  MVPs for SharePoint 2010: Debugging Techniques for SharePoint Online Applications - MSDN Blogs

May 31, 2011 7:04 PM

MVPs for SharePoint 2010: Debugging Techniques for SharePoint Online Applications - Bilim-Teknoloji | Positive Pozitive.NeT said:

Pingback from  MVPs for SharePoint 2010: Debugging Techniques for SharePoint Online Applications - Bilim-Teknoloji | Positive Pozitive.NeT

May 31, 2011 8:04 PM

MVPs for SharePoint 2010: Debugging Techniques for SharePoint Online Applications - Akl??ma Tak??lanlar | Zeytin.Net said:

Pingback from  MVPs for SharePoint 2010: Debugging Techniques for SharePoint Online Applications - Akl??ma Tak??lanlar  | Zeytin.Net

June 23, 2011 2:34 PM

Colin said:

fabulous, clean and clear guide, Thanks

June 30, 2011 2:34 PM

matt herb said:

can you upload these to office 365 public sites? Seems not possible.  

August 10, 2011 3:00 PM

CoreyRoth said:

@Matt I haven't tried it but it seems like you should be able to.  Remember you can just add t /_layouts/settings.aspx to your public URL.  From there you can get to the solutions gallery at /_catalogs/solutions/Forms/AllItems.aspx.

August 10, 2011 3:11 PM

Thommy said:

This looks perfect, but when i try to add the webpart to some page, it gives me an error "exception in the method 'execute' of the sanbox-codewrapper" (sorry, my error message is in german). Any ideas?

September 14, 2011 5:45 AM

CoreyRoth said:

@thommy there may be some unsupported code in the sandbox web part.  You might try starting over with a basic web part or removing any code that looks like it may require more permissions that allowed with SharePoint Online.

September 15, 2011 5:26 PM

Shashank Sharma said:

This is one of the best articles so far I have read online. No crap, just useful information. Very well presented.  Thanks for sharing with us. Its really helpful for beginner as well as developer. This link also explained very well about how to create and deploy webparts in sharepoint.

December 22, 2011 8:52 AM

Office 365 Technical Blog said:

Audience: Office 365 for professionals and small businesses Office 365 for enterprises

January 11, 2012 5:38 PM

Marcus said:

Thanks Corey, I was just checking out if I could load custom webparts to office 365 and I'm happy to hear I can!

February 14, 2012 4:08 AM

Shri said:

Hi Cory,

Thanks for the great post. I want to make use of the Skydrive for my storage. How do I interact between Office 365 site content and skydrive?


July 12, 2012 12:56 PM

CoreyRoth said:

@shri I am afraid there is no out-of-the-box integration between Skydrive and Office 365.

August 6, 2012 3:46 PM

Ofer Gal said:

Do you know if 365 allows calling WSDL web service calls from inside a sandbox solution?

July 5, 2013 1:04 PM

CoreyRoth said:

@Ofer Gal I don't know that it is supported from a sandbox solution.  The services are there, but I would be hesitant to develop a solution using them since they are deprecated now.

July 16, 2013 10:45 AM

Sumathi said:

Hi Roth,

I am having sharepoint 2010 wsp.I want to deploy this WSP into Office 365. Could you please help me on this.

Thanks in advance.

May 14, 2014 8:15 AM

Leave a Comment


About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2018 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems