Windows 8 Desktop
I have a Samsung Slate 7, which is the device that was given to the //Build/ conference attendees to run the developer preview of Windows 8 to best demonstrate the new Metro interface. However, I ended up waiting for the Consumer Preview release to really get going on Win8. To that end, I dedicated one of my laptops, in addition to the Slate, to running this new OS. Overall I find Win8 to be an interesting hybrid of classical Win7 desktop and the new Metro interface, which is awesome for touch on the Slate.
To be honest, the new set of interfaces took a bit of getting used to (especially using a mouse on a laptop), but I jumped right in with the beta release of Visual Studio 11 to start creating some OData apps, and especially Metro apps. I thought that at this point, I would take a short break and report that I have been doing with WCF Data Services on Win8.
In this first post of the series, I will focus on using WCF Data Services on in the Win8 desktop. While Win8 has the cool new Metro stuff, it also still runs regular Windows desktop apps. I will save the Metro discussion for the next post.
Consuming OData Feeds
The Windows 8 desktop with the Visual Studio 11 beta is basically the traditional Visual Studio development experience. However, Visual Studio 11 has been redesigned to be a bit more “Metro-ish,” including an entirely new set of black-and-white icons, which honestly took a bit of getting used to. Still, I was able to very easily create a new client application using C# to consume the public sample Northwind data service. Add Service Reference in Visual Studio still worked correctly to generate the desktop client proxy classes based on the .NET Framework 4 version of the WCF Data Services client. Everything worked as you would expect when creating a regular Windows 8 desktop application. Good to go there.
Creating OData Endpoints
While it may not be the ideal use of a Windows 8 client computer to host an OData endpoint, I wanted to try to create a new WCF Data Services ASP.NET application on this new OS. The first step was to use Visual Studio 11 to create the ubiquitous Northwind service running on IIS Express (the welcome replacement for the development server). The only difficult issue that I found here was trying to get Northwind running on SQL Server 2012; more about that later. Otherwise, creating this OData endpoint was as easy as the quickstart. Up next, the always challenging real IIS deployment.
Running a New OData Endpoint on IIS
Getting an ASP.NET-based OData endpoint running in the context of the developer (usually a box admin) using Visual Studio has always been very easy. Perhaps misleadingly so compared to getting the same data service running on IIS. This is why WCF Data Services has had the topic How to: Develop a WCF Data Service Running on IIS. However, this topic is not as useful on Windows 8 because a) web hosting components are not installed by default as they might be in Windows Server and b) the IIS account is different.
The following are the basic steps needed to deploy the OData endpoint to IIS running on a Windows 8 desktop:
- Install IIS and the following components/features:
- ASP.NET 3.5 and 4.5
- IIS Management Console
- IIS 6 Management Console
- WCF Services HTTP Activation (.NETFx 4.5 Advanced Services)
The following were the Windows Components that I needed to turn on to get the service running:
- Run Visual Studio 11 as administrator—otherwise you can’t create the virtual directory from VS.
- Create the WCF Data Service endpoint as a new ASP.NET Web application.
- On the Web project page, use IIS for hosting (by unchecking the Express box) and create a virtual directory for the application.
- Add a login for the “IIS APPPOOL\DefaultAppPool” account in SQL Server and create a user for this account in the Northwind database (see below), using this TSQL script:
CREATE LOGIN [IIS APPPOOL\DefaultAppPool] FROM WINDOWS; GO USE AdventureWorks2012 GO CREATE USER [IIS APPPOOL\DefaultAppPool] FOR LOGIN [IIS APPPOOL\DefaultAppPool] WITH DEFAULT_SCHEMA=[dbo]; GO ALTER LOGIN [IIS APPPOOL\DefaultAppPool] WITH DEFAULT_DATABASE=[AdventureWorks2012]; GO EXEC sp_addrolemember 'db_datareader', 'IIS APPPOOL\DefaultAppPool' GO EXEC sp_addrolemember 'db_datawriter', 'IIS APPPOOL\DefaultAppPool' GO
At this point, everything should run correctly.
Getting Northwind to Run on SQL Server 2012
As I mentioned, the biggest pain point that I had was trying to get Northwind to run on SQL Server 2012 Express Edition. Apparently, the old Northwind DB .mdb file is not compatible with this latest version of SQL Server. You are supposed to be able to just attach the old Northwnd.mdb file and the server will upgrade it for you, but I was getting errors when I tried this. Instead, I tried the Northwind install script. It also didn’t run because of the deprecation and removal of sp_dboption. Luckily, it was a pretty easy fix to remove those calls and replace them with (what I hope are) equivalent ALTER DATABASE calls. If you are interested, I have attached my updated version of the Northwind install script to this post (it's big ~1MB).
In the next post, I’ll share with you where I am and what I have seen with the Metro-side of the Win8 client.