Pixata Custom Controls
For Lightswitch

Recent Posts

Popular tags (# posts in brackets)

Anonymous types (3) ASP.NET (5) C# (3) C# tricks and tips (2) Computers (6) Design patterns (3) DomainDataSource (3) Dynamic data (4) Entity framework (3) Entity model framework (5) F# (3) LightSwitch (12) Linq (6) Microsoft (2) MVP (2) MVVM (2) Project Euler (2) RIA services (5) Silverlight (2) SQL Server (4) Unit testing (4) Visual Studio (7) WCF (3) WPF (3)

Gratuitous link to StackExchange

Archives


Categories


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Actually, as I'm self-employed, I guess that means that any views I expressed here aren't my own. That's confusing!


Acknowledgments

Theme modified from one by Tom Watts
C#/F# code styling by Manoli (for posts pre-2016) and Google code prettify (for post from Jan 2016 and beyond)


My rambling thoughts on exploring the .NET framework and related technologies

As I mentioned the other day, I have been taking a serious look at Microsoft Visual Studio Lightswitch, and was eagerly waiting for them to release it (as were a lot of other people, judging by the slow response time of the Lightswitch web site). They had announced that it would be available on the 26th July, but had forgotten that life actually does exist outside of the US. For some of us, it was the 26th for many hours before the Lightswitch people rolled into work! To make matters worse, they mistakenly sent out an e-mail at around 1pm (UK time) announcing that it was now available for download, even though the web site still showed links for the beta. Eventually it was clarified that the real release would be at 10am PST, which was erroneously reported in the forum as being 5pm UK time. Bashing the site from about 4:50pm, I eventually went to check about time zones, and discovered that due to summer time, it was actually going to be 6pm UK time!

Finally, at around 6:02pm, I managed to get hold of a link, and downloaded the ISO image. It actually came through very quickly, given the slow speed of the site earlier. Maybe everyone else had given up and gone home! Anyway, the install went very quickly and smoothly, and I had a little time to play before it was time to end for the day.

My first impressions were very positive, and I reproduced some work I’d done in the beta (on another machine) in a very short space of time. As I left the office, I was confident that I could get something fairly functional up and running by the next day (famous last words), which was a good job, as I had a client on my back, asking when the admin application for his data-driven web site would be ready!

Where it all went wrong part 1

My big mistake was sitting down in front of the computer the following day. It was a lovely sunny day, and on reflection, I think I would have been better spending it in the garden. I would probably have got about as much done!

The first thing that went wrong was when I brought the machine out of hibernation (I usually leave it switched on during the week, as it means that all my windows are open where I left them, enabling me to get on with some work instead of starting at the screen, trying to remember what I was doing the previous day!). After a few seconds, the machine froze. A bit bothered by this (as the machine is only a few weeks old), I ended up having to pull the plug (which bothered me even more) and restart it. It froze again, and I had to pull the plug again. I suspected that this was due to some updates I had done to the chip drivers late the previous afternoon.

To cut a long story short, I ended up using System Restore to take the machine back to where it had been a few days before. Obviously, this meant that Lightswitch wasn’t installed any more. No problem, just pull out the CD I’d burned and install it again.

Ha ha. The install failed badly. To cut an even longer story short, it took me several hours to get it installed again.

Finally, I was ready to start some real work with Lightswitch! It was only about twenty hours after I'd first installed it. Ho hum. As expected, once I was working, I got on famously, and managed to produce a pretty good first version of the admin application I needed.

Where it all went wrong part 2

Having got something worth showing the client, I realised that I needed to deploy it. Having read the deployment articles and watched the video, I was a little concerned, as it looked a little complex. I was wrong, it was a lot complex! Actually, that’s not even the start of it!

To cut yet another long story short, the prerequisites that you have to install insisted on trying to install SQL Server 2008 Express. Now maybe some people might want this on their servers, but I have the full version, so don’t need the express version (I’m not bragging, I got it free). However, you don’t get the choice, Microsoft want you to have it, so you’ll jolly well have it!

The problem was, that the installer didn’t actually install it at first, it just tried to install a service pack for it. This failed, logically, as I didn’t have the product installed, halting the entire prerequisites installation. I went through nightmares with this stupid installer, and eventually managed to persuade it to include SQL Server 2008 Express – which was ironic, as I didn’t want it in the first place!

Anyway, I was told by someone in a forum post that he had allowed it to install, then stopped the service immediately, and used the full version of SQL Server 2008. I decided to do the same. I think this was where it all went wrong the second time (I mean apart from the amount of hassle I had trying to get the server ready without installing SQL Server 2008 Express). So, thinking I was finally getting somewhere, I decided to try and deploy my application…

Where it all went wrong parts 3 and 4

In theory, deploying a Lightswitch application is really easy. You click the Publish button on the project property page, and follow the wizard. If you are on the same local network as your server, and have full administrative access to it, you should be able to deploy straight to it remotely. Note how I used the words “should be” in that last sentence. To cut a final long story short, it didn’t work. The wizard complained about things not being there that weren’t, but that I have no idea why it had any thoughts that were, it gave some very interesting, but ultimately unhelpful error messages, and basically refused to deploy my application.

In my eighth (I think it was, I lost count) forum thread of the day, I was advised to use the other method of deployment, whereby you create a disk file, copy it over to the server and use IIS management to import it. I wasn’t impressed by this, as I didn’t see why I shouldn’t be able to deploy remotely, but as it seemed to be my only option, I tried it.

Well, this was as much of a fiasco as the rest of the day. My first few attempts failed with weird error messages, but my fourth or so seemed to work. Sadly, even when I got something installed, the only tables created in my database were the ASP.NET role membership tables. None of the ones for my application were created. So, off I went again to the deploy wizard to try again.

Eventually, I gave up on that line, and created some scripts for the tables manually. I copied them into a query analyser window on the server and created the tables myself. So much for automated deployment! However, I was finally ready to go…

I was highly excited as I installed the application on my machine (I left it as the default out-of-browser application), and started it up.

I was asked for an administrator’s user name and password. Fair request as I had opted for authentication. Unfortunately, the import wizard in IIS had forgotten to ask me to create one, so I couldn’t log in. After about ten more attempts (each time having to deploy to disk, copy the file over, import it into IIS and answer the same connection string questions), I finally persuaded it to ask me for the log-in details.

With a huge fanfare of trumpets (well actually, without a huge fanfare of trumpets, but it would have been appropriate), I finally managed to log in to my new application! Hurray for me, hurray for Lightswitch, hurray for Microsoft, hurray for… wait a second, it’s not working!

Predictably, even though I had got as far as logging in, and could even create users and roles, I couldn’t actually do anything related to my own work. None of the screens that I had created displayed any data. There was a rather rude red X on each screen, with a message telling me that it couldn't load the data.

Off I went again to  the forum, to search around to see if other people had had this problem. I was sent on a wild goose chase from a post in the beta forum, where someone tracked the problem down to having spaces in the application name (huh?).  I messed around with this for some time, but it didn’t help.

Finally, someone suggested I look in IIS admin at the application, and see what connection string were stored in there. Lo and behold, there was one that was trying to access the SQL Server Express instance that I had stopped! Aaaaaaaarrrrrggghhhh!

I tried changing this connection string so that it pointed at the proper SQL Server instance, but this didn’t work either.

So, here I am, 7:30pm and off for supper. The client can download and install the application, but he can’t use it. I’m not sure which of us is less happy.

I’m sure that once I get this done the first time, subsequent deployments should go smoothly, but it has been a very painful and frustrating experience. I hope Microsoft put a lot of work into this for future releases.