Monday, February 14, 2011

Visual Studio and IE9 start playing nice again

If you installed IE9 Beta and use Cassini as your development webserver, you must have had the issue where 'Start debugging' yielded a 'Cannot display the webpage' error.

Either you uninstalled IE9 or you fixed the problem. If you are part of the first group, you will be happy to hear that this issue has been addressed in IE9 RC.

Source: IE9 RC minor changes list

Saturday, February 12, 2011

Reporting Services option grayed out on installing SSRS

Even though our title says Developer, it's hard for most of us to escape doing a system administrator task once in a while.

I had to add SQL Server Reporting Services to an existing SQL Server 2005 installation. This shouldn't be a big deal. Mount the SQL Server installation image, run the setup and follow the installation wizard to add extra components. Arriving at the step where I should be able to select Reporting Services, the Reporting Services option was grayed out.

After some Googling I found out that IIS needs to be installed to be able to install Reporting Services. I opened the Services snap-in and saw that the World Wide Web Publishing service already was installed, but it wasn't running... After starting the service, the Reporting Services option was no longer grayed out. The installer should have been smart enough to give a hint in my opinion, terrible user experience.

So to make a long story short, make sure IIS is installed and that the World Web Web Publishing service is running!

I hope I was able to soften some of the system administrator pain.

Sunday, February 6, 2011

Using JSON serialization outside a web context

You usually are in a web context if you are working with JSON, where JSON serialization almost always is encapsulated by the framework. You might accidentally come across scenarios where you want to serialize and deserialize JSON in a non-web context though.

Turns out this is fairly trivial since .NET 3.5. .NET 3.5 added the JavaScriptSerializer class. You can find this class in the System.Web.Script.Serialization namespace. To access this namespace you need to reference the System.Web.Extensions assembly.

From there on out, JSON serialization is very straightforward.

In this example I'm serializing and deserializing a Robot object.

   1:  public class Robot {
   2:      public string Name { get; set; }
   3:      public string Position { get; set; }
   4:      public string HomeWorld { get; set; }
   6:      public override string ToString() {
   7:          return string.Format("{0} ({1}) from {2}.", new object[] {Name, Position, HomeWorld});
   9:      }
  10:  }

From object to JSON string

   1:  var robot = new Robot() {
   2:      Name = "R2-D2",
   3:      Position = "Astromech droid",
   4:      HomeWorld = "Naboo"
   5:  };
   7:  var javascriptSerializer = new JavaScriptSerializer();
   8:  var robotAsJson = javascriptSerializer.Serialize(robot);
  10:  Console.WriteLine("Robot as JSON: " + robotAsJson);
  11:  //Robot as JSON: {"Name":"R2-D2","Position":"Astromech droid","HomeWorld":"Naboo"}

From JSON string to object

   1:  var robotFromJson = javascriptSerializer.Deserialize<Robot>(robotAsJson);
   3:  Console.WriteLine("Robot as object: " + robotFromJson);
   4:  //Robot as object: R2-D2 (Astromech droid) from Naboo.

If you are looking for a way to use JSON serialization in a web context, you might want to read these articles:

Tuesday, February 1, 2011

Why I still buy real books

As a technology geek, it should be hard to keep ignoring the latest generation of eReaders (read: the Kindle). With over three million devices sold, the Kindle has proven that it adds value to people's lives, and that it's a lot more than just a gadget.

Some of the most obvious benefits... You can carry a whole library in your backpack. The price of an eBook often is substantially less than the hardcover version. I am far from a Green, but I can't neglect the fact that no trees need to be chopped down to print an eBook. Reading a 1000+ page book in bed or next to the pool is the opposite of convenient.

Sufficient arguments to get a Kindle, but still, I just can't. Like serial killers collect trophies of their victims, I want to collect every book I have ever read. Unlike serial killers, I want to exhibit every trophy. I catch myself regularly halting for a few minutes when I pass by my bookcase. I love to have a look at the bookspines and associate the title with the time and place I read the book. Part of my love for paper books might also be caused by the global perception that books equal wisdom.

Any accomplices out there?