Sunday, October 10, 2010

Musings on the day to day in a developer's life

If you haven't already stumbled upon this you should really sign up for the podcast: This Developers Life. It's a show that focuses on the everyday things in the life of a software developer, it has very little to do with the techincal stuff but more with the people aspects of the business with is a very refreshing take since we tend to onlu focus on the techy stuff.

The music selection and mixing alone makes it worth listening to :) keep up the good work guys!

Wednesday, December 9, 2009

SkyDrive finally gets integration with Windows Explorer

When Sky Drive first came out from Microsoft I was really excited but alas there was no integration from Windows Explorer thus the intresst quickly faded, until today when I needed to share a binary file without having to require people to be registered and invited to my shared folder (which I need if I where to use my DropBox account) and to my suprise this was no issue at all for SkyDrive.

But still I was missing the windows explorer integration so I decided to give it one more go and boy am I glad that I did since it lead to the discovery of the excellent and FREE tool SkyDrive Explorer.

Screenshot of integration SkyDrive with Windows Explorer

Screenshot of accessing a folder on SkyDrive from Windows Explorer

Installing WPF Toolkit June 2009 on Windows 7 (getting rid of the heinous "WPF Toolkit requires .NET Framework 3.5 SP1")

Lately I've started to try out Windows 7 on my main development machine at work, this has worked really well and I'm really loving the Windows 7 experience... However there is always a darkside to everything, apparently the version of .NET Framework 3.5 SP1 that comes bundled with Windows 7 has a different version number than the regular download and thus you will bump into the following type of errors:



Imaging my frustration when googling around for this and not finding anything particularly useful (it's a rather annoying error message given the fact that it isn't correct since .NET Framework 3.5 SP1 is on the machine). Anyway after some email correspondance with a friend and colleague (thanks Samuel) my attention was turned to the Microsoft Platform SDK which contains a little tool called "Orca" which let's you inspect and modify the tables in an .msi file.

If you don't want to install the whole platform SDK you can grab the setup for "Orca" from my sky drive.


Now for the magic, to get around the error message we need to nuke the launch condition in question from the .msi file (there might be an easier way todo this so feel free to correct me by leaving a comment):



Step 1, Launch Orca.
Step 2, Open the .msi package.
Step 3, Find & select the launch condition entry in the navigation pane.
Step 4, Select NETFX35SP1_INSTALLED in the details pane & right click.
Step 5, From the context menu select drop row.
Step 6, Confirm the removal of the launch condition.
Step 7, Save the .msi package.
Step 8, Run the .msi package and voila no more error message.

Installing WCF LOB SDK SP2 on Windows 7 (getting rid of the heinous "WCF LOB Adapter SDK requires .NET Framework 3.5 SP1")

Lately I've started to try out Windows 7 on my main development machine at work, this has worked really well and I'm really loving the Windows 7 experience... However there is always a darkside to everything, apparently the version of .NET Framework 3.5 SP1 that comes bundled with Windows 7 has a different version number than the regular download and thus you will bump into the following type of errors:



Imaging my frustration when googling around for this and not finding anything particularly useful (it's a rather annoying error message given the fact that it isn't correct since .NET Framework 3.5 SP1 is on the machine). Anyway after some email correspondance with a friend and colleague (thanks Samuel) my attention was turned to the Microsoft Platform SDK which contains a little tool called "Orca" which let's you inspect and modify the tables in an .msi file.

If you don't want to install the whole platform SDK you can grab the setup for "Orca" from my sky drive.


Now for the magic, to get around the error message we need to nuke the launch condition in question from the .msi file (there might be an easier way todo this so feel free to correct me by leaving a comment):



Step 1, Launch Orca.
Step 2, Open the .msi package.
Step 3, Find & select the launch condition entry in the navigation pane.
Step 4, Select the ISWCFINSTALLED entry in the details pane & right click.
Step 5, From the context menu select drop row.
Step 6, Confirm the removal of the launch condition.
Step 7, Save the .msi package.
Step 8, Run the .msi package and voila no more error message.

Sunday, December 6, 2009

TFS Administration Tool Version 2.0 CTP now available for download

Finally it’s time for the brand new design of the tool to see the light, you can download the v2.0 CTP from here. Please take it for a spin and let us know what you like and not like about it (along with any potential problems you have).

The main new features in this release are:

  • Support for all available versions of Team Foundation Server (2005, 2008, 2010 Beta 2)
  • Complete redesign of the user interface
  • Multiple server connection
  • Bulk edit of users
  • Undo pending changes
  • Tracing

You can read more about the release on the homepage:

We are pleased to announce that the first community tech preview of TFS Administration Tool 2.0 has been released. This CTP marks a new beginning for the TFS Administration Tool as we have almost completely redesigned and rewritten the tool

The purpose for this rewrite was to provide a more stable and intuitive user experience.

Shortly we will start posting some walk through guides for common tasks.

Tuesday, December 1, 2009

Hans Rosling predicts the future ... When & How will Asia regain it's dominace over the world market?

Hans Rosling recently held a talk at TEDIndia about when Asia (India and China in particular) will catch up with the west and become the leading force in the economic world market. As usual he is very amusing to listen to and the stats he presents makes you think about the big picture as usual.

Hans Rosling: Asia's rise -- how and when

And while your at it make sure you watch some of his previous talks as well:

Hans Rosling: Let my dataset change your mindset
Hans Rosling on HIV: New facts and stunning data visuals
Hans Rosling's new insights on poverty
Hans Rosling shows the best stats you've ever seen

A fun note on the side is that when I sat down in the couch and opened up my laptop to write this post, I turned on the telly and guess what? It's a program with Hans Rosling on the Swedish television. Now that can't be just coincidence :)

Wednesday, September 30, 2009

Dropbox for iPhone is out!

Finally the wait is over you can now download the Dropbox client for your iPhone.

The GUI is fairly uncomplicated and follows the normal standards (for instances you swipe over the file to delete it). You can mark files as favourites and the will be available when offline. Most major file types are available for viewing along with easy access to sending a link via email.

There is support for media, photos & videos are pretty nice you can quickly upload either via existing photos/videos or simple take new and send it directly.

First impression of the streaming of music is not very good though since they tried to play my mp3 as a video :)

However what I really miss i the ability to move, rename and create & share files/folders. The application will be extended with this in future versions so that is no real problem.

As for simple editing of docx,xlsx and txt files is as far as I can tell not available nor planned which is major drawback :(

-- Posted from my iPhone

Monday, September 7, 2009

The Wait is over Spotify fot the iPhone is out!!!

Just wanted to spread the joy if you live in Scandinavia, United Kingdoms or Spain you can now download the iPhone client for Spotify (a music streaming service) provided you have a premium account with them.

This is step in the right direction for digital media distribution.

-- Posted from my iPhone

Saturday, August 29, 2009

Watch Nordic Developer Conference 2009 from you favorite couch

If you also where unable to attend the NDC09 you’ll be happy to hear that the talks are now available for downloads go here and you can get them in a convenient torrent format so that you can download the whole shebang in one swoop (be warned though it’s a large download +30GB).

The speakers list of the  NDC09 was very impressive… Robert Martin, Craig Larman, Scott Hanselman, Phil Haack, Mary Poppendieck and Scott Bellaware just to name a few.

Thursday, August 27, 2009

Taking SQL Azure for a test spin (it’s dirt simple)

Earlier this week I received my invite to the SQL Azure CTP so I obviously threw myself at taking it for a test spin, and I must say that it was a sweet experience (a part from the fact that my SQL DDL is a little rusty). Anyway I figured that I should write a few lines about the experience but first let's just get some basic facts out of the way, what is SQL Azure?

Microsoft® SQL Azure Database is a cloud-based relational database platform built on SQL Server® technologies. With SQL Azure Database, you can easily provision and deploy relational database solutions to the cloud, and take advantage of a globally distributed data center that provides enterprise-class availability, scalability, and security with the benefits of built-in data protection, self-healing and disaster recovery.

The about quote is taken from the Windows Azure Platform site and as it states you can now deploy a relational database in the cloud and accessing it via the TDS protocol using ADO.NET and ODBC (there is even a driver for PHP if you need that).

Anyway enough with the chit chat let's get our hands dirty in some code... The app we will run through here is an extremely simple an silly notebook in the cloud which you can insert some reminders in a then go back and see what you should do (the whole application took less than one hour to get up and running, writing this post took far longer than that).

First out you have to activate your invite (if you haven't signed up you can do it here) and get your SQL Azure database provisioned. When you have done that you get to access the management portal:

Currently you can only manage your connection strings and create and drop databases, but since you can’t manage logins we might as well drop straight into the sqlcmd tool (in this version you can’t use the Management Studio it is not supported yet) and start by creating  a small database. When you create your databases and logins you need to be logged in to the master database.

Once you have fired up a command prompt we issue the following command to connect to the master database:

sqlcmd –U <admin>@<servername> –P <password> –S <servername>.ctp.database.windows.net –d master

Now let’s create a database called MyCloudDB and a user called MyCloudUser:

CREATE DATABASE MyCloudDB
GO
CREATE LOGIN MyCloudLogin WITH password='1tsCloudyInSeattle'
GO

Let’s switch over to our new database and create some tables and grant our user some access:


sqlcmd –U <admin>@<servername> –P <password> –S <servername>.ctp.database.windows.net –d MyCloudDB


Then we issue the following statements create a user and a table where we can store our notes:


CREATE TABLE CloudNotes (ID int IDENTITY(1,1) PRIMARY KEY, Note nvarchar(500))
GO
CREATE USER MyCloudLoginUser FROM LOGIN MyCloudLogin
GO
GRANT SELECT,INSERT,UPDATE,DELETE ON CloudNotes TO MyCloudLoginUser
GO

Now we are ready for some code, first let’s write the snippet needed to put the reminders up in the cloud:


    public void InsertNote(string note)
{
SqlConnection cn
= new SqlConnection("Server=tcp:<yourservername>.ctp.database.windows.net;Database=MyCloudDB;User ID=MyCloudLogin;Password=1tsCloudyInSeattle;Trusted_Connection=False;");
using (cn)
{
SqlCommand cmd
= new SqlCommand("INSERT INTO CloudNotes Values (@Note)");

cn.Open();

cmd.Connection
= cn;
cmd.Parameters.Add(
new SqlParameter("@Note", note));
cmd.ExecuteNonQuery();
}
}

And finally the code required to retrieve the notes so we don’t forget to but that milk on our way home:


    public List<string> ListNotes()
{
List
<string> result = new List<string>();

SqlConnection cn
= new SqlConnection("Server=tcp:<yourservername>.ctp.database.windows.net;Database=MyCloudDB;User ID=MyCloudLogin;Password=1tsCloudyInSeattle;Trusted_Connection=False;");
using (cn)
{
cn.Open();

SqlCommand cmd
= new SqlCommand("SELECT ID, Note FROM CloudNotes ORDER BY ID", cn);
SqlDataReader dr
= cmd.ExecuteReader();
while (dr.Read())
{
result.Add(dr.GetInt32(
0).ToString() + " - " + dr.GetString(1));
}
}

return result;
}

That’s all there is to it as I said in the title dirt simple :) if you want to read more about the limitations and how to get going checkout MSDN documentation on SQL Azure. I’ll probably post more as I dabble around with it.

Saturday, August 22, 2009

Getting the dreaded "The fully qualified file name must be less than 260 characters" when publishing test results in TFS 2008

During the last week I've had some issues with getting an old set of tests to run in the automated build process. The reason they had been excluded before was that the author had used .xml files to drive his test suite and was unaware of the functionality in MSTest that let's us specify deployment items through the .testrunconfig file (provided that you run you tests using a .vsmdi file).




Anyway, even though I don't particularly fancy the approach of using external files to drive the test (there are good scenarios but in my opinion they should be oriented more towards simple parameter driving of test not complex object serialization, but that is a post in itself if I get around to it sometime).



The problem once I got the test to run on the server (some shmuck had deselected the deploy alternative for the assembly containing the unit tests in the build targeted by the automated build), that the testrun results simply wouldn’t publish instead we got this message in the log:



Waiting to publish... Publishing results of test run tfsservice@LIVMSRV228 2009-08-21 12:56:49_Any CPU_Release to http://livmsrv246:8080/Build/v1.0/PublishTestResultsBuildService2.asmx... ....The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. MSBUILD : warning MSB6006: "MSTest.exe" exited with code 1.


What happened was that the tests ran ok and you’d see the results ok in the log but as soon as Team Build tried to publish the results we ended up with a complaint about a too long path. Unfortunately no matter what amount of logging you switch on the log won’t tell you which file is the problem and in our case this particular test result file was actually on of the shorter paths :). So after a fair amount of head-butting I managed to get it working and guess what the problem resided in the deployment items that we selected using the .testrunconfig. Our structure was heavily nested with long self-explanatory names for readability :) which is good, but since they somehow are involved in the publishing step (I haven’t had the time to drill down into what happens here so if you have some insight into this feel free to comment about it) and thus you are restricted to the 260 characters for the fully qualified path name of the deployment item.

Simplify Photo & Simplify Music ... It's got to be one of the coolest iPhone Apps so far!

Just felt that I had to share the joy. I just installed and tried out the coolest app to date for my iPhone (the app works for iPod Touch as well). It's a company called SimplifyMedia and they have produced a piece of streaming software available for PC,MAC and Ubuntu which let's you share your photos and music from a machine at home and then access it thrue an application called:

Simplify Photo (about 1$)
and not to mentioned what could well be a worthy rival to the long awaited Spotify iPhone/iPod client, altough you are limited to your own music collection which will most likely have trouble matching the depth and breath of Spotify's music archive.
Simplify Music 2 (about 6$)
After you've downloaded and setup an account and selected the folders to share your ready to go and can access your photos and music from everywhere.

Monday, August 10, 2009

Tips n Tricks: Moving TFS to another server and getting Error 3154: The backup set holds a backup of a database other than the existing database

Another issue that I ran across today when trying to restore our TFS backup onto the freshly installed TFS server what the fact that due to various discrepancies in the environments I ended up getting the following error message when trying to restore my Reporting Services and SharePoint databases:

Error 3154: The backup set holds a backup of a database other than the existing database

So after banging my head awhile I did a bit of searching and sure enough I stumbled upon the following post that explains how to get around it.

To sum it up it is quick simple you have to switch back to TSQL mode and open up a query window and make sure you are currently in the master database and then issue the following command:

RESTORE DATABASE YourDatabase
FROM DISK = 'C:\YourDatabaseBackup.bak'
WITH REPLACE



That’s all there is to it, so far I’ve only encountered this issue with the Reporting Services and SharePoint databases, never with the TFS databases.

Tips n Tricks: Moving TFS to another server and getting "Scale-out deployment" is not supported in this edition of Reporting Services

Today I was mucking about with restoring our TFS environment on a different server to create a backup environment where we can do our migration testing and bumped into some minor issues. I Figured that I should post them, if not for anything else they'll server as a reminder to self the next time around.

Anyway the problem concerns getting the following error message when you try to access your reports:

The feature: "Scale-out deployment" is not supported in this edition of Reporting Services

So what’s the deal with this then? Well as the documentation states:

A scale-out deployment refers to two or more report server instances that share a single report server database

This functionality is not available in the standard edition of SQL Server and the problem I ended up with is that once you follow the steps in the guideline document (How to: Move Your Team Foundation Server from One Hardware Configuration to Another).

My problem was that once I had restored the encryption key for my Reporting Services I ended up with two entries when running RSKeyMgmt –l, to get around this I ran RSKeyMgmt –r OLDDTInstanceID.

Tuesday, July 7, 2009

How to get the Using statement to work when dealing with interfaces directly.

UPDATE 2009-08-04: As pointed out in the comments by Marc L there are some issues involved in using the techniques described below the primary problem concerns the fact that you might incur an exception in the finally block of the using statement this would lead to any code below the using statement to not run. Also if you throw an exception in your code and the dispose call yeilds an exception this will mask your exception which you will never see. You can read more about it in this msdn article: Avoiding Problems with the Using Statement

Just recently I did some coding in a project and was faced with something that took me awhile to figure out so I thought I'd write a line or two about it. But before we continue let me state that this post deals with WCF based services in a VB.NET application.

The thing is that personally I'm not very fond of using the "Add Service Reference" in Visual Studio (there are obviously situations where it is useful but most of the times I prefer to have more control over the generated proxy), so what I usually end up doing is to spawn up my own proxy using the ChannelFactory and simply add a reference to the assembly containing the service contracts.

The problem arises when you start working with interfaces to make sure that you can inject your dependencies into your code to be able to implementing proper unit-test. When you do this and try to use the Using statement to implement the disposable pattern and make sure your resources are release in a timely fashion.

Dim factory As ChannelFactory(Of IMyService) = New ChannelFactory(Of IMyService)("MyBinding")
Dim myInterface as IMyService = factory.CreateChannel()

Using myInterface
...
End Using
This example code will generate the following complier error:

'Using' operand of type '…IMyService' must implement 'System.IDisposable'.

So after banging my head against the monitor for awhile I stumbled upon a blog with an example where the author used the As operator to perform a cast in the using statement, so I figured that this hade to be doable in VB.NET as well.

Dim factory As ChannelFactory(Of IMyService) = New ChannelFactory(Of IMyService)("MyBinding")
Dim myInterface as IMyService = factory.CreateChannel()

Using DirectCast(myInterface, IDisposable)
...
End Using

The above code will work and even though it isn’t as slick as it’s counterpart in C# it will do the trick. Now we are able to both utilize the disposable pattern to make sure we are not forgetting to release our resources and still make use of dependency injection in our code and improve our testability.

There is no magic here once you think a little about it what the using statement wants is simply a reference to an instance that implements the IDisposable interface which the proxy returned by CreateChannel does. So we just need to give the compiler a little nudge to get it to work.

UPDATE 2009-08-04: However the problems don't stop here. If we wrap an object implementing IDisposable inside a using statement and the Dispose method throws exceptions we are toast. This will lead to all kind of weird behaviours when dealing with error situations.

First out we need to handle the fact that any exception being raised within the using block will be supressed by exceptions raised from inside the Dispose call. Secondly we have the issue that if you have any code that needs to be executed after the using block, you will be in for a nasty suprise since it will not run if an exception is raised from within the dispose method.

The easiest way to get around this would be to implement a helper object dealing with the disposing logic that we can pass to the Using statement. This object can then supress any exceptions being raised during disposal and do the appropriate logging. The code below implements such a wrapper object that will handle this for the WCF scenario, you could easily modify it and just pass in any object implementing IDisposable and just deal with the logging and exception suppression.

Imports System
Imports System.Diagnostics
Imports System.ServiceModel

Namespace DisposablePattern

Public Class CommunicationObjectScope
Implements IDisposable

Private scoped As ICommunicationObject
Private disposed As Boolean = False

Public Sub New(ByVal co As Object)
If TypeOf co Is ICommunicationObject Then
scoped = co
Else
scoped = Nothing
End If
End Sub

Public Sub Dispose() Implements IDisposable.Dispose
Try
If Not disposed Then
If Not scoped Is Nothing Then
Select Case scoped.State
Case CommunicationState.Faulted
scoped.Abort()
Exit Select
Case Else
scoped.Close()
Exit Select
End Select
End If
End If
Catch ex As Exception
'TODO: replace with more approriate logging!!!
Trace.WriteLine(ex.ToString())

'NOTE: Do NOT throw or rethrow from within this
' exception block since this will mask the
' original exception.
End Try
End Sub
End Class
End Namespace



By using this class we would end up with code looking like this:

Dim factory As ChannelFactory(Of IMyService) = New ChannelFactory(Of IMyService)("MyBinding")
Dim myInterface as IMyService = factory.CreateChannel()

Using co As New CommunicationObjectScope(myInterface)
...
End Using

To summarize you can use the DirectCast approach if you have controll of the object implementing IDispsable, but if there is the slightest chance that an exception might occur from within the Dispose method you should go for the wrapper approach.