Microsoft.WindowsAzure.StorageClient is not actually on Azure

And neither is Microsoft.WindowsAzure.Diagnostics.

It’s ironic that the diagnosis of Windows Azure roles failing to start up is that the Diagnostics assembly isn’t present.

I’ve spent the better part of a day trying to figure out why things weren’t working. According to countless forum posts, blog articles and MSDN articles, the main reason that roles fail to fire up and end up cycling between initializing and busy is that there are dependent files missing. I assumed (wrongly) that the Microsoft.WindowsAzure.* assemblies would be present because… well… it’s Microsoft Windows Azure. I was wrong.

It kind of makes sense, because you might not want to use all features of Azure. But you have to forgive me for assuming they’d be there.

I figured it out by running Intellitrace on the instance. I could download the Intellitrace log and I could see that there was a nice big System.IO.FileNotFoundException. It couldn’t load Microsoft.Windows.StorageClient. I did a bit more research and eventually found out that you need to Copy Local that assembly, and Diagnostics, too.

A post from Think First, Code Later, was the final bit of info that made everything else make sense!

This has been a big weekend for blog posts for me, hasn’t it?

Running ASP.NET MVC 3 on Azure

If you have successfully installed an app running MVC 2 on Azure, and then try to upgrade it to MVC 3, you might run into some troubles.

What might help is to ensure that you have also deployed the new assemblies. MVC 2 is part of .NET 4.0, and its assemblies are included in the standard Azure image, but the new ones aren’t. You have to deploy them yourself.

They won’t get deployed by default because they are in the GAC. You have to make sure that “Copy Local” is selected for the relevant MVC assemblies.

The instructions on how to upgrade and MVC 2 project to MVC 3 are in the release notes, and involve replacing some of the old references with the new ones. But those assemblies have dependencies that aren’t copied.

The assemblies I needed to run an MVC 3 project (using Razor) on Azure are:

  • Microsoft.Web.Infrastructure
  • System.Web.Mvc
  • System.Web.Razor
  • System.Web.WebPages
  • System.Web.WebPages.Deployment
  • System.Web.WebPages.Razor

I’m not 100% I needed System.Web.WebPages.Razor, but it seemed like a good one to have.

I did not need System.Web.WebPages.Administration. If you include that, you need to include NuGet as well.

I don’t actually know what any of those assemblies specifically do (I don’t know what the WebPages or Microsoft.Web.Infrastructure assemblies are for), but this is what I’ve needed to deploy to get it to work.

You can’t use Google Analytics on wordpress.com

I wish I knew this before I spent $12 on a custom domain for blog.zoopcast.com. You can’t use Google Analytics on a WordPress.com site.

I think the advantages of hosting the blog on their infrastructure outweigh the inconvenience of not having all metrics in one place (at least at this early stage), but it sure is an inconvenience.

Hopefully the WordPress.com Stats feature is good enough. From what I’ve read on TechCrunch though (and this is what sparked that whole “RSS is dead” fight last week), the stats that WordPress.com gathers don’t always match up with Google Analytics.

Azure 1.3, Rewrite module and a ‘Faulted’ System.ServiceModel.Channels.ServiceChannel

I recently updated to Azure SDK 1.3. Then I tried to debug my solution locally. This is where the trouble began. The problem was that I was using the IIS Rewrite module without having it installed. Rewrite was part of Azure SDK 1.2, but it has to be installed separately for 1.3. I guess I should have read the release notes.

Here is what the problem was, and how I found the solution.

I would consistently get the following exception:

System.ServiceModel.CommunicationObjectFaultedException was unhandled
Message=The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at Microsoft.WindowsAzure.Hosts.WaIISHost.Program.Main(String[] args)
InnerException:

It didn’t make any sense.

Most of the support out there (like here) suggested that it was because I was using a using (...) { } block around a ServiceClient. Something about exceptions that get raised during the ServiceClient‘s Close method being swallowed up into that generic one. But it wasn’t that. My code didn’t consume any WCF services.

I thought it might have been the Facebook SDK. It couldn’t have been log4net or Netwonsoft.JSON, either.

Another suggestion was that WebRole’s Web.config file was not writeable. That wasn’t the case either.

It turns out it was the use of the section in Web.config. What also didn’t help was that I had two sections by mistake as well (the result of a bad merge). According to the Windows Azure SDK Release Notes, “If you wish to use the IIS URL Rewrite module, you must install it and configure your rewrite rules.”

Once I installed that, I was able to run my solution with the Rewrite rules intact.

I suspected that the problem wasn’t really that the IIS Rewrite module hadn’t been installed, but that the unrecognised Web.config section caused it to fall down. That suspicion was confirmed when I added a element to my Web.config. The exact same CommunicationObjectFaultedException was raised.

So the golden rule is to your Web.config if you get a CommunicationObjectFaultedException when running an Azure solution locally.

Images showing on iPhone Simulator but not device?

If you’re working on an app (Zoopcast, say) and you’re finding that images that you’ve got in your application bundle are showing up when you’re running in the simulator, but not on the device, check the case of your filenames.

I thought there might have been some sort of image format problem that [UIImage imageNamed:] uses, but I was wrong. It was simple case sensitivity.

I’m guessing that my computer has a case-insensitive filesystem whereas the iPhone and iPod I am testing on presumably have a case-sensitive one. And that is where the problem arose.

WCF adding trailing slashes

I’ve run into some weird issues, which I’ve finally figured out, when building the Zoopcast web service, which will eventually become the REST API for Zoopcast when we’ve got a useful number of users and a stable API.

The problem is that if there is an empty URI, WCF expects a trailing slash, and will helpfully redirect you to it. That’s what you’d usually expect when you get to a directory on a web server. But it’s not what I want.
It turns out that it’s by design. If I put everything under one giant WCF service, it would be fine, as there wouldn’t be an empty URI (e.g. it would be “users” rather than “”), so there would be no redirect.

I think the only way that I can fix this is by using IIS’s URL rewriting to rewrite “users” to “users/”. It’s not the most ideal solution, but it will work for now. I prefer that than to create an über web service.

Any other suggestions welcome!

UPDATE: Seems that my solution (I should have tried it before I posted it) doesn’t help. I think it’s to do with there being two methods that have the same URL template. One for POST, one for GET. It’s annoying. Another update (if I remember) to come…

CLLocationCoordinate2DMake is new in iOS 4

I hadn’t done any Core Location work before iOS 4 came out. But now I am. And I ran into a very odd EXC_BAD_ACCESS bug when running on an iPod touch that’s running iPhone OS 3.1.3. I pinpointed the problem (actually, I think it was only a problem, because I did a lot of other refactoring to get to this point) was with CLLocationCoordinate2DMake. And I finally realised when looking in the header that it’s new for iOS 4. Which is why it fails under iPhone OS.

My fault for being a CL newbie.

In any case, I figure I should share this with others because my searches were fruitless. Enjoy!

UPDATE: The static inline function described by Cocoanetics was immensely helpful and also helped with the next problem I encountered – distanceFromLocation being introduced.

Nexus One update trashes Twitter?

Here’s a weird one. I have just updated my Nexus One to build FRF83D. And the official Twitter app has disappeared. Completely. I had to reinstall it from Android Market.

The app was preinstalled with the previous build, and you couldn’t get rid of it. But removing it when it is already installed and being used, without asking, is a little weird.

I don’t know if it’s just my phone (and if so, what did I do to cause it?) but if it’s more widespread, to quote hungrybear9562, “what does this mean?”

The Twitter app was launched at Google I/O back in May, and was apparently built by Google. They announced that the source code would be released. It never happened, and the most recent refresh of the app changed the UI to be very similar to the iPhone app. Which is odd, because the Twitter app was one of the first to use the new UI features of Android.

Perhaps something soured in the relationship between the two companies after the updates?

Or perhaps this has something to do with Google’s social play, whatever that will be.

Or perhaps it’s just Google realising people don’t want apps bundled with their phones.

It’s probably the latter, but it would be more fun if something sinister was going on.

In other news, beta testing of Zoopcast is going well. We should be with Apple for approval this week. Follow @zoopcast (if you’ve still got the Twitter app) for updates.

To Three20 or not to Three20…

My answer, and one I wish I came to a bit earlier, is not to Three20.

And the reason is this. It is a completely different architecture to the native UIKit framework. Which is fine, it’s supposed to be. But because of this, making what should be minor changes to the appearance of a table view cell, for example, can become troublesome.

Some of the problems I had were because of the lack of documentation. I’m not complaining about that, because the open source project grew out of an internal one which, if it’s like almost ever internal project I’ve worked on, everyone on the team knew pretty intimately. Documentation will improve. And that’s a good thing.

The one thing that I do like about Three20 is the whole request model thing. If you wire up a TTTableViewController, TTDataSource and TTModel, all the UI around loading and reloading data is pretty much taken care of for you.

But the other UI stuff is more trouble for me than it’s worth. I was initially attracted by the URL navigation feature, but really, I’m just adding another layer of complexity, especially when it comes to passing objects rather than scalar strings and numbers as parameters. And even then, there is unnecessary conversion to and from strings to create the URL and then extract the parameters that will get passed to the init method.

So I will be migrating away from Three20 in subsequent builds of Zoopcast. Yes, this is the first time I am blogging about Zoopcast, the startup I founded in July. We’re nearly ready… stay tuned (by following @zoopcast, who is eerily silent at the moment).

But that’s not to say that it’s not a good library. It is. And will be better after the bug crushing week that is happening now as well. But it’s just not appropriate for this case. It obviously has its uses – it is what one of the most popular iOS apps, Facebook, is based on.

Facebook Places has launched in the UK. The End.

At the risk of turning this into a blog that’s exclusively about Facebook Places, I figure I should write a very short piece about Facebook Places actually launching in the UK. So here it goes..

Facebook Places launched in the UK some time this morning.

If you’re wondering why I was looking at Facebook Places in the first place, follow @arunstephens on Twitter, and you’ll be amongst the first to know when my new (location-based, obviously) project is launched.