Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Advanced Scenarios for LightSwitch

Advanced Scenarios for LightSwitch

This item in japanese

LightSwitch brings together a number of technologies including Silverlight, Managed Extensibility Framework, and WCF RIA Services. If LightSwitch becomes popular, developers who understand these technologies will have a significant advantage over those who simply wire forms together using the design surfaces.

LightSwitch, Microsoft’s answer to lightweight CRUD style applications, has recently been released in two parts. The first is the LightSwitch Beta 1, which is matched with a Training Kit. We have already reported on the core functionality, which is the ability to quickly create simple business applications using variety of backend technologies. Today’s piece looks at some of the advanced features.

The first scenario covered by the Training Kit is building a custom control. When doing normal programming with WPF or Silverlight, creating custom controls is more or less just something to do if you happen to need one. With LightSwitch they take on much more significance. In effect you have two classes of developers, those who simply wire together controls and those who define them.

Control creation for LightSwitch isn’t exactly easy with 5 projects needed for a new control. First there is the control itself, the “Client” project, which is coded in Silverlight. This is paired a “Common” project, also in Silverlight, that has meta-data about the control. Next up is the “Designer” project, which is used by the LightSwitch design surfaces inside Visual Studio. Since this code is run directly by Visual Studio it must be in CLR 4. Part of the reason for these projects is that you need to hook into extension points exposed via the Managed Extensibility Framework.

Once all of the code is done you still need to package the control. There are two packaging projects, one is specific to LightSwitch while the other is a normal VSIX project. If you don’t recall, that is the package format for any Visual Studio extension. To test your control library you must install the VSIX package, at which point you can start using the new control in your LightSwitch application.

The second “advanced” scenario really shouldn’t be. LightSwitch accesses non-SQL based data sources via WCF RIA Services. These are built like normal RIA services, optionally with the client access part turned off so that only LightSwitch applications can access it. The normal RIA operations such as initialize, submit, query, insert, update, and delete will be needed. While building RIA services are strangely more difficult than they seem like they should be, at least there are no VSIX packages to worry about.

A warning: the training kit does not install itself in the normal places such as Program Files or the Start menu. So if you can’t find it later look for folder called “LightSwitchTK”. On my test machine this was installed under the root directory.

Rate this Article