SQL Server Express: Failed to generate a user instance of SQL Server error

I ran into a quirky issue while re-tooling from VS 2008 to VS 2010. In case anyone runs into it, I thought it might be good to have a heads up. Instead of running them side-by-side, I completely uninstalled VS 2008 and did a clean install of VS 2010. As it turns out, that caused a bit of a problem with SQL Server express. This one was a fun one to track down, so some background information is in order.
I was working on a proof-of-concept and needed a data import for some sample code into SQL Server express. Why not just use the regular edition of SQL Server? The folks who wrote the sample code probably didn't want to assume that everyone had a regular SQL Server instance running in their dev environment and didn't want to exclude anyone from using their code. It so happens that I am running a regular SQL Server instance on my machine, but I wanted to accurately repro the setup for for the sample code based the provided instructions, which called for SQL Server express. I probably could have just cheated and imported the database into my regular SQL Server instance, but that would have also introduced more variables into the equation to validate my POC than I was willing to deal with.
Every time I tried to access the imported SQL data, I kept getting this error:

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance

I checked the network stack, security permissions, everything. As it turns out, the SQL Server express persists some files in your app data directory that don't get cleaned out when you uninstall and reinstall. It's a problem when you attempt to spin up a user instance because a file already exists in your app data directory that SQL Server express is attempting to re-create. It might have been a bit easier to troubleshoot if it told you about the file it failed on in the initial error message. Instead, it just reports on the failed instance.
Solution? Delete the SQLEXPRESS folder under C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\ so that SQL Server express can re-create the files. If you've got some things in there that you want keep using, you might have to do more precise surgery and find the offending files. In my case, I didn't.
Did I figure this one out all by my lonesome? Not entirely. I still had to dig through the error logs to find the problem, but I'll give credit where credit is due for the solution:

Windows Phone 7 Trial API Walkthrough

The Windows Phone 7 Trial Mode functionality is a power and simple tool. For those unfamiliar, the Windows Phone Marketplace allows for developers to list their applications in three ways: Free, Buy, and Try-Before-Buy. In order to be more marketable, it is usually a better option to offer customers the ability to try out an application before they give you their hard earned money. Another difference between this approach and other phone marketplaces is the user experience for upgrading their app from trial to full version. It is a simple two-click process, one click to upgrade, the other to confirm the purchase.

Implementing the trial mode code is a very straight forward exercise. Here is an example:

Microsoft.Phone.Marketplace.LicenseInformation license = new Microsoft.Phone.Marketplace.LicenseInformation();

public string ApplicationTitle
        {
            get
            {
                if (license.IsTrial() == true)
                {
                    return "My App (Trial Version)";
                }
                else
                {
                    return "My App";
                }
            }
        }

The above example demonstrates how we can change the way the app behaves for a trial user versus a fully licensed user. In this case we are changing the Application Title of the app. A trial user will see “My App (Trial Version)” at the top of their screen and a fully licensed user will see “My App”. Not very limiting, I know, but it demonstrates how easy it is to implement this in your code.

The code implementation is simple because Microsoft is doing much of the heavy lifting here. The Microsoft.Phone.Marketplace.LicenseInformation class uses Microsoft’s Zune Marketplace to check the license currently installed on the phone. It returns true if the license is a trial version and false if it is the full version. This leaves the developer to spend writing code and polishing the user experience rather than writing their own licensing services or writing a completely separate trial version of their applications.

IE8 and ASP.NET Sessions

One behavior that seems to have inexplicably changed between IE8 and IE7 is the handling of session cookies. In IE7 (and 6) each browser instance and tab had it’s own session cookie and, as a result, session on the server. Not so in IE8! Every tab and browser instance (with some minor exceptions) now shares the same session cookie. When designing ASP.NET applications, this is something you need to be aware of. If you, for example, store an item currently being edited in session state and a user opens two browsers to edit two different entities, expect all kinds of strange results. If you want to test the behavior of a specific browser to see for yourself, visit this page. In my quick test, the latest version of Chrome behaves just like IE8.

So how do you make sure an application can support multiple browser windows? Well, there are a couple options, none of which is completely satisfying:

  1. Eliminate the use of Session State and switch to cookies, hidden form elements or some other client side mechanism.
  2. Enable cookiesless sessions (URL rewriting). Beware that this approach has some security implications as well as some practical effects on things like bookmarking and URL sharing.
  3. Train your users to select “New Session” from the File menu in IE8. Not exactly easy since the menus are hidden by default. If you enable them you’ll notice that you have both “New Window” and “New Session” as options. The latter will allow multiple browsers running different sessions.

The moral of the story is that if you decide to use session state, be sure to plan for users opening more than one browser window.

SQL Azure 50GB Databases Now Available

Ahead of the promised June 28 target, the SQL Azure team updated SQL Azure with Service Update 3 (SU3), providing new database sizes up to 50GB.

Web Edition databases can now be scaled to either 1GB or 5GB, while Business Edition databases have increments of 10GB, 20GB, 30GB, 40GB, and 50GB.

The Web Edition tiers are $9.99 and $49.95 monthly, while the Business Edition tiers are increments of $99.99.

The new database tiers come with a new pricing model that evaluates your maximum daily usage, and each day’s cost accrues at the appropriate tier, based on the database edition chosen. For instance, if a 20GB Business Edition database never exceeds 10GB, its daily rate accrues at the 10GB tier. On days in which the database exceeds 10GB, it accrues at the 20GB tier.

For more details, see my post here.

Azure Guest OS 1.4

A few days ago, the Windows Azure team released a new Guest OS, version 1.4. The Guest OS is what runs in Azure’s environment and hosts your running applications.

The latest update includes fixes for Azure Drives and WCF Data Services. It also includes several security patches. If your Azure deployment is configured to automatically use the latest OS, then you’re already running Guest OS 1.4. This might have breaking changes for your code if you are using WCF Data Services.

For more details, see my post here.