Building LightSwitch Extensions Part 1

Microsoft shipped version 1.0 of Visual Studio LightSwitch in July as both a stand-alone product and an add-on to the full version of Visual Studio. While the product is targeted at quickly creating useful line-of-business applications, it's quite capable of doing much more. The key to rapid development centers around accessing data and presenting it to the user on template-driven screens.

Extending the functionality of Visual Studio, LightSwitch is not as difficult as it sounds. Out of the box the product comes with a minimal number of supported extensions including money and phone number data types and a picture and text custom layout control. Extensions fall into four basic categories consisting of business type, data source, theme and shell. While you only need the Visual Studio LightSwitch product to build applications, you'll need a full copy of Visual Studio 2010 with SP1 to build extensions.

Setup

You must be running Visual Studio 2010 with Service Pack 1 (SP1) installed before you can install any of the additions needed for developing LightSwitch extensions. Next, you must install the Visual Studio 2010 SP1 SDK. Then you'll need to install Visual Studio LightSwitch 2011 followed by the Visual Studio LightSwitch 2011 Extensibility Toolkit.

The final requirement will be to install Silverlight 4.0 for developers if you haven't already done so. Visual Studio will let you know if this isn't installed the first time you try to create a LightSwitch extension project. It's important to point out at this point that Silverlight plays a key role in the development of custom controls. That means you'll need to get familiar with XAML if you plan on building any Silverlight controls.

The Basics

Once you have everything installed you should see several new options on the Visual Studio New Project menu as shown in Figure 1. Language choices include C# and VB.net. After you have created a new extension project you should see a number of entries in the Solution explorer as shown in Figure 2. This is essentially the same list of projects you'll see with a new LightSwitch solution with the addition of Lspkg and Vsix. We'll take a look at these two new items next.

Visual Studio New Project menu
Figure 1: Visual Studio New Project menu

Visual Studio Solution Explorer
Figure 2: Visual Studio Solution Explorer

LsPkg is short for LightSwitch Packaging project and contains information about all the moving parts contained in your application. This is the project you will add new items to from the list of available extension types (Figure 3 shows the list). To do this, simply right-click on this project and then select Add New Item. Choosing to add a new data source will create a template file with the code as shown in Figure 4. Choosing to add a new control will add a number of new things to your project as shown in Figure 5. Now all you have to do is add the code to make your new extension do what you need. We'll cover that in a future article.

Add New Item - LightSwitchExtension2.LsPkg
Figure 3: Add New Item - LightSwitchExtension2.LsPkg

Add a new data source
Figure 4: Add a new data source

Add a new control
Figure 5: Add a new control

The VSIX project is where the actual Visual Studio Extension will be built. Once you have your new extension created you must distribute it as a VSIX file for others to install. It's essentially the same format used for any Visual Studio extension.

Resources

Microsoft has done a decent job of providing tutorial information to get you started developing your own extensions. You'll find them in the MSDN LightSwitch Developer Center under the Extending LightSwitch heading. A quick Google search will turn up lots of additional resources as well. Many commercial vendors such as DevExpress, Infragistics, Rssbus, and Telerik are starting to release LightSwitch-specific versions of their custom controls.

There's also a collection of user-contributed extensions and links to commercial offerings on the Visual Studio Gallery site. Use the search box to look for LightSwitch-specific extensions. You can take the LightSwitch product out for a spin with the free trial version available on the main LightSwitch site. You'll need a full-blown version of Visual Studio if you're itching to get started developing your own extensions. You might as well go ahead and get an MSDN subscription so you can have access to both along with a whole host of other Microsoft products.

Next time we'll take a deep dive on actually developing a few extensions.



Related Articles

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

  • "Security" is the number one issue holding business leaders back from the cloud. But does the reality match the perception? Keeping data close to home, on premises, makes business and IT leaders feel inherently more secure. But the truth is, cloud solutions can offer companies real, tangible security advantages. Before you assume that on-site is the only way to keep data safe, it's worth taking a comprehensive approach to evaluating risks. Doing so can lead to big benefits.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds