onsdag 22 september 2010

LightSwitch - Errors

In case any of the (10 or so) who read this blog felt like it was time to try out LightSwitch themselves, I post this one about an error you might receive.
It turns out that some of us receive an error about missing assemblies when creating a lightswitch project. I received this one myself on one of my machines where I had Vs2010 and the Silverlight packages already installed.
This error has to do with WCF RIA services and the order of the installation. Some googling on the subject will give you more details about it.

The solution is to uninstall WCF RIA services, download it from silverlight.net and then install it again. If you have problems with that (yes I had that to), you might have to do some registry hacking as explained here.
(I only needed to remove the first entries in his list, then it worked for me)

Well, can't be to easy to get the environment running, can it??

tisdag 21 september 2010

LightSwitch - Creating the Data

So, to create a table for your data you can either click the "Create new table" link on the startpage or you can right click the "Data Sources" folder in the solution explorer and choose "Add Table".

The next step is to rename your table, either in the designerarea by clicking its name or in the "properties" view. With that out of the way, start designing your table. You wil lnotice that you got the "id" column by default, but the rest is up to you. Since I plan to put administrators in there, I choose to add FirstName, LastName, Email and Phone in mine.

The "Type" field needs some extra care. This field wil give your Screen the suitable component, like a datepicker control for a "date" field, but will also provide basic validation, so give it an extra thought when designing your table. I have strings for my name fields, but an "EmailAdress" type for my Email and "PhoneNumber" for my phone.

With the table ready, we will just need a simple screen for editing its data. Right click on the "Screen" folder in the Solution Explorer and choose "Add Screen". The "New Screen Dialog" will present you with the available templates. Choose "Editable Grid", change its name and pick your table as the source in the "Screen Data" dropdown list.


And that's it, you should be able to run your basic application by hitting "F5" inside Visual Studio. Try to add some data in the Grid and make sure the validation works

LightSwitch - creating a project

So, the LightSwitch BETA is installed and I have spent a few minutes down at the LightSwitch Developer Center. Its time to fire up Vs2010 and take the first babysteps with this tool.
When firing up VsStudio, choose "LightSwitch" as the template and the language of your choice. Note that you won't be able to change it so choose wisely ;)

When the new project is created it will prompt you for a DataSource. You will either connect to an existing datasource or create a new one in the included SQL Express.

Notice also the interesting "solution explorer". The Default is to show your solution in the "Logical View", which means "Properties", "Data Sources" and "Screens". Screens are the LightSwitch names for views, and we will play around with them in the next step.




Lightswitch

As you might know, Microsoft is working on an "all in one" tool for quick developments called Lightswitch which is available as a beta. The download installs whatever you need, or in case you have an existing vs2010, gives you a new Template in Vs2010 based on Vb or C#, whatever you prefer.

Lightswitch uses common Microsoft technologies and products behind the scenes but glue it all together in a more rookie-friendly presentation.

I'm always interested in magic tools who promise to cut my development time so I intend to take this one for a ride. Stay tuned for more information