Tuesday 19 May 2009

TypeMock ASP.NET Bundle

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.

Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out FREE licenses to bloggers and their readers.

The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.

Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.

The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you'll get a license automatically (even if more than 60 submit) during the first week of this announcement.

Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.

Go ahead, click the following link for more information on how to get your free license.

Sunday 3 May 2009

Windows 7 RC and Me

This weekend I installed the recently released Windows 7 RC.

My goal was to dual boot Windows XP and Windows 7.  Apparently that was not to be.

I had most encouraging attempts at installing the new release over the weekend.  My main issue was how insanely long it took to install.  When I say long, I mean it was counted in hours.

The first install was taking so long that I also forced a reset.  It was sitting on Completing Installation for so long without any sign of progress other than the tiny little animation with the “…” that I started to hold the Power button on the PC to force a reset.  One Mississippi… Two Mississippi… Three… Holy cr4p the install just came to life!  Abort Reset!  Abort Reset!!!

The first install seemed to work just fine but I went and did a silly thing.  I have a number of partitions set up and I have assigned specific letters to them in XP which I wanted to do in Win7 as well.  The only issue is Win7 decided to assign “D:” to the XP partition.  I didn’t like that as I always set “D:” to my “Development” partition.

So I happily went along an dutifully renamed all the partitions.

Then it didn’t want to reboot anymore.


There is a trick to reassigning a System drive.  I had forgotten to implement it.  Time to reinstall Win7 again.

The next time, just play failed.

It ended up taking so long that next attempt that I gave up and left it “installing” over night.  Unfortunately at some point it crashed and every time it tried to recover it would complain that it had previously crashed and I should restart so that it would recover and continue where it left off.  It kinda felt like Groundhog Day seeing that message over and over again.

So then again I go through the pain of insanely long installs… except the third was relatively speedy.  For a moment there I had tried disconnecting my external drives having vaguely recalled that there was an issue with them some time again.

It seemed to do the trick.

Shame this install didn’t pick up the “Legacy” install of XP.

I tried everything I could think of.  I even resorted to restoring the XP partition from back-up even though it was a little dated - by only a couple of months mind you.  Strangely that didn’t help.  The XP partition wouldn’t boot and would keep reporting the Boot.ini file was corrupt and the NTDETECT failed.


So maybe I should take the plunge and commit to Win7 100% and finally dropping XP once and for all.

Time for another install.  No point keeping that XP partition any longer, I’ll move Win7 into pole position on the HDD.

So here I am, onto my fourth or fifth install of Windows 7 RC.  It took forever again… Sigh.

I have no major complaints really other my installation issues.  Most of which were caused by my own ineptitude but the speed of installation was worrisome.

I now have a shiny new install of Windows 7 RC.  I am now rested and calm again.  All that is left now is to install every other application I need to complete my PC…  Visual Studio… Add-ins… SQL Server… Subversion… Browsers… Tools… Utilities… ad infinitum…

A geeks job is never done…

Tuesday 10 March 2009

What I learned today with... Visual Studio Team System Database Edition GDR

You cannot add multiple Server Projects as Database References in a Database Project

Apparently it balks at this.

I was trying to separate logins into a Server Project and the users in the Database Project. Seemed logical to me. Except I was going about things the wrong way.

What I missed was a very important point that was staring me in the face whenever I was adding a database reference.


Maybe I should be referencing mainly other Database Projects.

I had a second database that my main database was going to be referencing. For some reason I got it into my head that referencing a Server Project was the way to go. But apparently Database Projects only like referencing one Server Project and I was already doing that to bring in the Logins and other Server settings. I had to create a Database Project for the second Database.

Finally, by adding a Database Project for the referenced database I am able to build and deploy my main database.

Of course I did have a reason for not wanting to create a Database Project for the second database. That reason being the second database is actually a common database that is used across multiple applications and their corresponding databases. But I didn't want to tie the Database Project to a single solution.

So how do I organise Database Projects that will span multiple solutions?

The only solution I have is to create a special solution just for the common database that only includes the corresponding Server and Database Projects for that database. Next I add those two projects as "existing" projects into the solution that will reference that database (typically via some view for example.)

It seems like a cluggy solution but it is all I have at this moment.

Wednesday 18 February 2009

ASP.NET MVC and the VB XML ViewEngine - Interim 1

This is just as an interim update.

Things have been moving a little slow of late and Part 2 of my journey into ASP.NET MVC and the Spark View Engine has had a minor change of direction. Mainly, I stumbled upon a fantastic new view engine for ASP.NET MVC that utilises the new language feature for VB.NET... Xml Literals.

I just <3 Xml Literals!

Just as a quick example from the standard website that is generated for you when creating a new ASP.NET MVC Project.

Here is the original code for the Index.aspx view...

<%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

   Home Page

<%= Html.Encode(ViewData("Message")) %>

To learn more about ASP.NET MVC visit http://asp.net/mvc.

Here is the same view using the VB Xml ViewEngine...

Namespace Views.Home
Public Class Index
Inherits SiteMaster

Public Overrides Function Render() As System.Xml.Linq.XElement

  Me.ViewData.Add("Title", "Home")

  Return MyBase.Render()

End Function

Public Overrides Function RenderContent() As XElement

<%= Xhtml.Encode(ViewData("Message")) %>

To learn more about ASP.NET MVC visit http://asp.net/mvc.

End Function End Class End Namespace

This is just a very simple example, but it can be very powerful too.

For example, now my views are completely contained with my classes as Xml Literals, the rendered page output is checked at compile time instead of runtime.

I will be explaining more about this new development in the next part of this journey. Until then, note that I have decided to drop my plans to use the Spark View Engine in favour of this new VB.NET Xml Literal based View Engine.

Until then, you can check out this View Engine at it's source, Dmitryr's Blog. There is also an informative interview with Dmitryr at Channel 9.


Saturday 7 February 2009

Template Updates

I have been mucking around with the template today. No major changes other than widening the page layout and separating the css into its own file. It gives me a little more room to play with.

The other interesting bit is I have added to the right-hand side a feed from my shared notes in GReader. I still need to fix up the style so that is looks part of the theme but I am quite pleased how easy it turned out. Though I'll need to add some checks into it so that it doesn't end up displaying "undefined" for certain fields from the feed :(

Tomorrow I shall finish up the styles for the shared notes and add a twitter feed too.

ASP.NET MVC and the Spark ViewEngine - Part I

I've finally decided it is time to try out ASP.NET MVC and see if it has any advantages for me over traditional ASP.NET WebForms.

I have only ever create websites using PHP (many moons ago) and ASP.NET WebForms 1.1+.

Over the past number of months, I have been intrigued to try out the new-fangled MVC technology. At the same time, I thought I'd also delve a little in the Spark ViewEngine instead of the built in View Engine. As well as trying out for the first time, Unit Testing with the Visual Studio default test suite, as well as TypeMock. For data access, I will using the latest build of SubSonic 2.1 including a few minor tweaks I've added myself.

I will also be using Visual Studio 2008 as my main development environment and GIT for source control. The development machine is running Windows XP Professional x64 with IIS6.0(ish).

At this moment, ASP.NET MVC is at RC1 and the Spark ViewEngine is currently at version 1.0.317.

As a side note, my main development language of "choice" is VB.NET. Mainly because my work environment encourages its use. A short while ago Roy Osherove was looking for developers who use VB.NET to help test and suggest improvements to VB.NET friendly features for TypeMock which had previously been aimed more towards C#.

It has been a while since I was given the special licence to use TypeMock for testing purposes so I thought now is a good time to fulfil my promises.

This will be the first time that I have actively implemented a proper testing framework including using mocking so please forgive me if my first run at this goes completely haywire.

The Project

In order to try out these new technologies, instead of just putting together lame demos that serve no purpose at all, I will be building a real live application based on a very basic booking application I put together for a friend of mine.

The application as it stands today can be seen at http://www.horsearena.co.nz and is built on ASP.NET WebForms with a SqlServer 2005 backend that is accessed via SubSonic 2.0. It originally usedd NHibernate over (Gods forbid) an MS Access database.

Shamefully, this site is very neglected and is in dire need for an Extreme Makeover.

Therefore I thought it would make an ideal candidate for some MVC love.

Where to Start?

To begin with the first step seems to be to install ASP.NET MVC, Spark and TypeMocks. This is the easy bit. What to do next is the hard bit.

This may be my first project to use all these new tools but it doesn't mean I am completely new to the concepts involved. I have been attempting to keep up to date by reading and listening to as much source material, articles, reviews, tutorials and podcasts as I have time for. This is no easy feat and I am humbled by my colleagues and peers who are able to keep abreast of all these technological changes.

I have been following the concepts behind Test Driven Development and Domain Driven Development etc. and it all looks fine and dandy but I am not yet fully convinced on it's merits or best practices. Basically for this project I will be just winging it a little but leaning towards TDD I imagine. At least my goal is to at least develop some sort of test suite.

Adding a New Project

The next step at least is to add to my solution a new ASP.NET MVC project. This at least creates a nice new project for the new MVC application. At the same time, the project wizard asked if I wanted a test project too so I said, "Yes!"


To the left is the basic project structure that was created. Note that I have made one minor addition to the project. I have included jquery 1.3.1 and the corresponding vsdoc for intellisense.

Technically speaking the vsdoc is for jquery version 1.3 but I am hoping it shouldn't matter to much. In Scott Guthries blog he mentions that the release version for ASP.NET MVC, it will come bundled with version 1.3.1.

This is all fine and dandy but does it work?!

Um... Not exactly :(

Now this is not the first time I started a brand new ASP.NET MVC project though it had been in this particular machine instance.

My first problem I had was the 404 error I was getting.

Why the heck was I getting a 404 error on a brand new web application?

After banging my head against my desk for a moment while checking the properties of the website in IIS and making sure the ".mvc" extension was correctly hooked up, I thought I would check the IIS logs.

Note, there are some handy scripts found in <Program Files>\Microsoft ASP.NET\ASP.NET MVC RC\Scripts to register/unregister the ".mvc" extension for pre-IIS7 and IIS7 classic mode.

Step 1.. Find the logs!

This wasn't quite as hard as I expected at first. It would seem the default location is C:\WINDOWS\system32\LogFiles\W3SVC1\. After quickly scanning the log for today I see the culprit...


WTF! Oh No! I know what I did!

I was playing around with the Web Platform Installer from Microsoft. A very handy tool for setting up your machine for web development. Why hadn't they come out with this to begin with? It makes it easy to install everything you need, and apparently things you do not necessarily need. In my case, I selected UrlScan 3.1 to be installed. I didn't really need UrlScan. I didn't really understand at the time what UrlScan actually was. I know now. Kinda...

For whatever reason, UrlScan was not liking my web application. Apparently I could configure somehow but I couldn't be bothered so I just uninstalled it.

That didn't work.

Despite uninstalling it was still hooked into IIS. The UrlScan dll was gone from it's installation folder. I tried restarting IIS numerous times. But it refused to let go. I gave up trying to work out how to disable UrlScan and decided it was time for a reboot.

One more thing, because I'm using IIS6 I need to alter the routing in the Global.asax.vb file because I need to specifiy an extension to be mapped for ASP.NET MVC since this application will end up on a shared host where I have no control over the configuration of IIS. As such, the extension I'm going to use is ".aspx".

I replaced the original route...

  routes.MapRoute("Default", _
                  "{controller}/{action}/{id}", _
                  New With {.controller = "Home", .action = "Index", .id = ""})
With the following...
  routes.MapRoute("Default", _
                  "{controller}.aspx/{action}/{id}", _
                  New With {.controller = "Home", .action = "Index", .id = ""})

  routes.MapRoute("Root", _
                  String.Empty, _
                  New With {.controller = "Home", .action = "Index", .id = ""})

Phil Haack has a handy guide for this. Note with ASP.NET MVC RC1 you don't seem to need the fix for the Default.aspx page as it already handles the problem with routing the default page.

Yay! The almost-out-of-the-box ASP.NET MVC application works!


In Part II I begin adding jQuery and the Spark View Engine.

Syntax Highlighters Example

Javascript Code Prettifier

class Voila {
 // Voila
 static const string VOILA = "Voila";

 // will not interfere with embedded tags.

Syntax Highlighter 2.0
class Voila {
 // Voila
 static const string VOILA = "Voila";

 // will not interfere with embedded tags.

Saturday 24 January 2009

I like StackOverflow.com but...

StackOverflow is a programming Q & A site that's free to directly copy a line from their "About" page.

But it makes me feel... Inadequate.

But asking and answering questions, other users can vote you up or down to earn (or lose) reputation points.

I have my moments of trolling the site looking for questions I can answer to gain a little rep but I find it a struggle.

How do people manage to devote so much time to gaining so much reputation measured in the thousands?

Is there some trick involved?

I do find the site invaluable for finding the answers for problems I have be stuck with but I sometimes it doesn't come through for me.

I had one particularly nasty problem that I'd keep bumping into for some strange reason.

I have an ASP.NET TreeView control on the page, the user selects a node. How can I tell if the user clicks the selected node again? No event was triggered for clicking the selected node, only for when a non-selected node was clicked.

I couldn't get a satisfactory answer so I updated the post to state that I'd look to develop a solution when I had the time.

In the meantime, my question seems to be getting a significant number of views. Nobody seems to be attempting and answers and nobody seems to be voting.

Eventually I did find the time and I thought I'd find a reasonably good solution. I promptly submitted the solution as an anwser to my own question.

The trouble now is how to get my answer at the top of the list? With the number of views my question has had, surely people are interested in the answer? Is there a reason for not voting up my solution? Is my solution really that bad that they couldn't even be bothered to vote my solution down?!

Maybe it's just me.

I just can't help but get concerned that my solution gets no recognition.

Maybe I should start trolling for some simple questions again... Don't I have something even vaguely more interesting to do?


Just as a side note, when looking at my stats for the question I posted, it seems to show "2k" as the number of views.

But when I select the question, it then states the question has been viewed 1,887 times.

I am pretty sure the 2k does not equal 1887 or even approximate it all that closely.

Finally! I'm a Real Developer!

Today, I finally recieved my MCPID and Access Code.
MCP Logo
It took a while in coming but it hadn't been a priority to sort it out.

I had studied for and passed the exam while working for a former employer. One month after passing the exam I left for greener pastures.

I never received my MCPID or Access Code.

This past week my colleague James Hippolite finally convinced me to sort out my MCPID and graciously offered to help.

He find an email for me to contact, to which I wrote a most heart felt letter discribing the heartache and pain I'd endured in the nearly two years of not being able to log into the MCP website.

Of course I could have gone to more courses and sat more exams but I've been of the mind that certification wasn't for me.

But now that I have finally sorted out my MCP log in and associated it to an email, and I guess Passport/Live ID perhaps, that I shall never consciously lose again - perhaps I shall look more seriously at extending my certifications.

In any case, I am happy that I now have a printed document to show that I've at least achievement one credential... Albiet a little long in the tooth...