Monthly Archives: December 2011

Configuring Windows 7 Machine to Host LightSwitch Web Applications

Most LightSwitch users want to deploy their Web applications to their own machine for testing and learning purposes. It is very easy to configure your machine to do so. In fact, you only need to do a few things. LightSwitch will do the rest. This post covers what you need to do to get your machine ready. My next post will cover the deployment process itself.

The instructions/examples are focused on Windows 7 and Internet Information Services (IIS) 7 and are intended for those who are in development, learning, or test mode. For full Web server configuration advice, check out Beth Massi’s post, “Deployment Guide: How to Configure a Web Server to Host LightSwitch Applications.”

These instructions assume you are using Windows 7 and have created your data entities in LightSwitch (intrinsic database). If your LightSwitch application uses external data, then ignore the bits on needing SQL server. In that case, you have already connected to a database.

What You Need

The basic components you will need to have installed are SQL Server (or SQL Server Express), Internet Information Services (IIS) 7, and .NET Framework 4.x.

  • If you don’t have SQL Server installed on your local machine, you can use any that you have access to. If you don’t have access to one, install SQL Server Express.
  • If you don’t have IIS installed, go to your control panel and enable it. (Very easy instructions)
  • Make sure you have .NET Framework 4.x. IF you don’t have it, get the latest here.

How Web Deployment Works

Publishing to the Web with LightSwitch is technically called 3-Tier Deployment. Your application is viewed in the browser on the client (Tier 1), it is hosted on IIS using LightSwitch application services (Tier 2), and uses data in the form of SQL Server or SQL Server Express (Tier 3).

Sound complicated? It’s not because we use LightSwitch. As long as you have the basics installed and configured (IIS, .NET Framework 4, and SQL Server or SQL Server Express), LightSwitch will do the rest.

Configuring Your Environment

There are just a couple things you need to do to make sure your environment is configured correctly: make sure your IIS application pool is using .NET 4.0, create a database, and set SQL Server to mixed authentication mode.

Setting up IIS

IIS hosts applications in application pools and each application pool has a property to specify which version of the .NET Framework to use. IIS’s Default Web Site is hosted by the DefaultAppPool and commonly uses .NET 2.0. Your LightSwitch application needs to use .NET 4.0 so you need to check the  .NET Framework version property and change it if necessary.

  1. Open the Computer Management console and expand the Services and Applications node.
  2. Select Internet Information Services Manager and the ISS page will open.
  3.  Expand the server node in the connections pane and select Application Pools. The list of application pools will open.
  4. Select DefaultAppPool, click Basic Settings, and set the .NET Framework version property to .NET Framework v4.x.
  5. Click OK to complete the change. You may also want to restart IIS for good measure.

That’s it. IIS is now ready!

Set up SQL Server

LightSwitch needs a database with mixed authentication to deploy correctly. Mixed authentication allows SQL or Windows authentication. You will see why when we get into the deployment process.

All you need to do is create a blank database and enable mixed authentication. I use SQL Server 2008 R2 and Microsoft SQL Server Management Studio, so these instructions use those applications.

Start by creating the database.

  1. Open your SQL Server management tool and connect to your server.
  2. Create a blank database by right-clicking on the Databases node and selecting New Database (the New Database window will open)Name your database and click OK.

Now set the authentication mode.

  1. In the management screen, right-click on the server node and select Properties.
  2. This will open the Server Properties window.
    In the Server Properties window, select Security from the page menu and click the SQL Server and Windows Authentication mode radio button.
  3. Click OK.

You Are Ready to Deploy

Those few steps are all the prerequisites you need to start the Web publishing process in LightSwitch. My next post will cover that process.

Tagged , ,

Using a SharePoint Calendar with ComponentOne’s Scheduler for LightSwitch

This is a cross post… also posted on ComponentOne’s blog (“Using SharePoint Calendars with ComponentOne Scheduler for LightSwitch). To put it in context, Scheduler for LightSwitch is an extension that adds a calendar screen to a LightSwitch Project. You can download a trial over at if you are interested in kicking it around.

Microsoft Visual Studio LightSwitch has a great feature nobody talks about: the ability to use SharePoint as a data source. Data is created and stored in SharePoint all the time and that data is often useful in business applications. Imagine a project management or time management application, for example. Chances are that there is a SharePoint calendar somewhere that has useful data for that application.

ComponentOne Scheduler for LightSwitch extension gives you a snap-in Outlook scheduling application. All you need to do is add the screen to your project and select a data source. With this extension, you can add SharePoint calendar data to your LightSwitch application very easily.This article explains how you can use ComponentOne’s Scheduler for LightSwitch with a SharePoint calendar to create an Outlook-style scheduling application without code.

Setting up the Calendar Data Source

Scheduler for LightSwitch needs a table with seven fields to work properly. These fields are ID, Subject, StartTime, EndTime, Body, Location, and Properties. A standard SharePoint calendar has fields that can map to each, with the exception of Properties. You will need to create a Properties column.

Below are instructions to start from scratch. If you are using an existing calendar, make sure you first follow the instructions for creating a Properties column.

To create a new calendar, access SharePoint’s create list dialog, select Calendar, and name it.

Once the calendar is created, open the list setting page and click the Create Column link. Name the new column “Properties,” keep Single line of text selected and clear the Maximum number of characters field. There is often a large amount of data in the Properties field, so keeping the limit can cause errors.

Make sure you add at least one record to the list. A holiday is an easy example.

You now have a calendar that Scheduler for LightSwitch can use!

Creating the LightSwitch Application

Create a new LightSwitch project and select Attach to External Data Source from the start screen.  The Attach Data Source Wizard will open.

Select SharePoint and click Next.

Enter the URL to the site that hosts your calendar, select your login method, and click Next. Note that you just need the top level URL, not the path directly to the calendar. You will select that in the next screen.

Select the list (or lists) you would like to include, name it, and click Finish.

You should see a visual representation of the list in the LightSwitch designer.

Now, you can add the ComponentOne Scheduler screen. Click the Add Screen button, choose ComponentOne Calendar Screen, and select your list from the Screen Data drop-down.

When you click OK, you will see the design view for the Calendar screen you just created. The next major step is to map the screen data fields.

Click Holidays in the tree view and you will see Row Template properties appear in the Properties pane. Map the following:

  • Primary Key Property:  Id
  • Start Time Property: StartTime
  • End Time Property: EndTime
  • Subject Property: Title
  • Body Property: Description
  • Location Property: Location
  • Properties Property: Properties

You are now ready to run your new application.

Click the Start Debugging button or press F5.

You now have a basic scheduler application. This application will do the following:

  • Display items on the SharePoint calendar.
  • Allow you to export the entire calendar to iCal or XML.
  • Add events to the calendar one by one or import iCal or XML files. Anything entered will also appear in the SharePoint calendar.
  • Print a view.
  • Look at day, week, and timeline views.

More Features

Wait, there’s more!

By default, grouping is turned off. You can add a toolbar that allows users to group by resource, contact, or category. To turn the feature on, go to the screen designer, click on C1Scheduler, and check the Show Group Commands in the Properties pane.

Click the Start Debugging button.

You can also map more tables or lists to application.

To associate a separate data source (such as a contacts list), click Add Data Item to add the desired query to the screen. Add the collection to the end of the screen layout, then change the default control (DataGrid) to C1Contacts as shown in the following figure.

Note that the data item must exist and be part of the project. See the Adding Other Data Sources topic in the Scheduler for LightSwitch documentation for more details.

That’s All Folks

The combination of LightSwitch and ComponentOne Scheduler has made it very easy to create a scheduling application – even with SharePoint data. What are you using it for?

Tagged , , , ,