Who said building Visual Studio Extensions was hard?

comments
In years past building Visual Studio Extensions have often been considered the realm of the big boys. Staff working at Jetbrains or the Microsoft employees of the world. Last year I saw a talk given by Mads Kristensen aimed at taking away some of this stigma and showing how easy the guys at Microsoft have tried to make it for developers like you and me to just up and write extensions. I’ve been wanting to build one ever since, but haven’t had a good enough excuse to jump right in – until now. Here follows the creation of “OnCheckin Web.config Transformer”.

Html.AntiForgeryToken – Balancing Security with Usability

comments
When writing forms for your ASP.Net MVC websites the common approach to ensuring only real people use them site is to simply add an Html.AntiForgeryToken() to your form’s view mark-up and controller and be on your way. I've recently found out this approach while simple, can actually have pretty serious affects on both how your visitors use of your site as well as their view of it’s professionalism and stability – two things you really don’t want any trouble with.

Sorrow and Elation – Why Reflection Isn't Always Your Friend

comments
Over the past two weeks I've begun moving a lot of my hosting infrastructure onto Microsoft Azure. This has consisted of all sorts of configuration – virtual networks, VPN's, backups, servers, databases and sites. One of my sites uses Code First Migrations at it's core, and during the migration simply nothing would work. After much pain and frustration I made the worst mental leap a developer can make: I came to the simple conclusion that is was everyone else's fault. Like most of these kinds of problems, I was to blame all along.

Entity Framework Code First Migrations in Teams

comments
Migrating to a Code-First or Model-First approach to database development can be very liberating. At the end of the day your database is just a way of storing state, so getting away from the implementation details can really help speed up development and allow you to focus your efforts. Code First’s awesomeness aside, when you try and implement this kind of paradigm shift within a team you unlock a different set of problems. Here are two potential ways to alleviate some of the headaches.

Teaching Your Application to Read

comments
Geeky salesman have spent decades selling us a pipedream of the end of “Tree based communication”. To date not much has changed and I’m not holding my breath. In the mean time, what do we do with all this paper? If like me you are dabbling with ways to get your code to convert the physical to the digital, I’ve got news for you: Smarter people have already solved the problem for you and it’s simply a matter of plug and play.

Integration Testing FTP Connections in .Net

comments
When writing testable code your first port of call is often to abstract any dependencies and make them easy to mock. This is the same for any of your codebase that talks to FTP servers. Testing the way your code behaves under real world conditions makes integration tests important regardless of abstraction though. Here’s a simple trick to test FTP code in the wild.

Building an Image and Video Viewer for Microsoft Surface 2.0 in No Time At All

comments
I’ve been lucky enough to have access to a brand new Surface 2.0 (Samsung SUR40) recently, and wanted to try my hand at developing for the platform. As with most things, the easiest way to learn something is to set yourself up with a little project – I’m going to build a very simple Image “Attractor” to start. This will allow you to move, resize and rotate images and videos on the screen of the device. The Surface development community appears to be a little cloak and dagger, with very little information being shared; something hopefully I can positively contribute towards changing by documenting my journey.

Things I Missed So You Won’t Have To – WP7 SDK

comments
During my development journey with Windows Phone 7 , there have been a number of things that I overlooked when writing your first app – things I wished I’d kept front of mind. None of these items are necessarily difficult or complicated things to cover off, so I thought I'd mention them here to save you the trouble, and at the same time show you ways to overcome each of them.

Building an Image and Video Viewer for Microsoft Surface 2.0 in No Time At All

comments
I’ve been lucky enough to have access to a brand new Surface 2.0 (Samsung SUR40) recently, and wanted to try my hand at developing for the platform. As with most things, the easiest way to learn something is to set yourself up with a little project – I’m going to build a very simple Image “Attractor” to start. This will allow you to move, resize and rotate images and videos on the screen of the device. The Surface development community appears to be a little cloak and dagger, with very little information being shared; something hopefully I can positively contribute towards changing by documenting my journey.

Xbox Kinect Hub Remake - An Introduction To Natural User Interfaces

comments
I first started playing around with my Kinect at home just to get a feel for what was involved in working with the SDK – I must say that I, like many of you, was amazed, and still am, at how awesomely simple and beautifully designed the API’s in the Kinect NUI framework are. A lot of people have written little Kinect demo’s showing how to create buttons and detect hand location, but I thought I’d try something different. So I set out to mimic some of the Xbox Live's interface elements in WPF.

Writing your own custom ASP.Net MVC [Authorize] attributes

comments
ASP.Net’s [Authorize] attribute is another cool feature that makes it easy to add authentication at the Controller level when building a website, but the real goldmine here is that like nearly everything else in ASP.Net MVC, you can pick apart the functionality and extend it yourself – In this post we will take a look at creating our own custom Authentication attribute.

XMLSerializer - Removing Namespace & Schema Declarations xmlns:xsi xml:xsd

comments
The XML Serializer built into the .Net framework is a pretty cool side-utility when working with anything that consumes XML. A few years ago I posted about how your should Make your XML strongly-typed: Because you can and it’s easy in which I discussed how easy and awesome it is to use the XSD.exe tool to quickly convert an XML file into a XSD and then further covnert into a Serializable c# class file. The only not-so-perfect part of using the XML Serializer is that it by default adds namespace and schema attributes that point at the W3C standard declarations – but it’s just as easy to remove these so your resulting XML looks perfectly like your original XML file.

Solved: Why Don’t ApplicationBar Bindings Work? – Windows Phone 7 SDK

comments
One of the subtleties I've found recently while working with the Windows Phone 7 SDK is found when working with the ApplicationBar programmatically. There are a number of differences that the ApplicationBar has when compared to a normal Windows Phone 7 Silverlight control – these very differences can be really frustrating if you are not aware of them as they stop you from interacting with it in the same way you do other Silverlight controls. Hopefully after we’ve taken a closer look it will make sense why they are so.

ASP.Net WebForms – Partial Page Caching With The Substitution Control

comments
Often when using built-in ASP.Net WebForm Caching to speed up a page’s output time, people feel pigeon holed into either caching the whole page, or setting up output caching for the majority of controls on the page individually. An often overlooked approach is to use the Subsitution control. This allows you to have your cake and eat it too by caching the whole page, and yet still updating a part of the page on every load.

How to use ZoneInfo/TZ Time Zones in .Net Applications

comments
While recently working on the live tile implementation for my Windows Phone 7 hobby project InTheKnow, I had a need to implement Unix Time Zone support using a TZ database. This list of Time Zones is widely used by Unix systems around the world as their source of Time Zone information. Sadly Microsoft’s .Net framework doesn’t have any support for this library – but like other parts of the framework that developers have found to be lacking, there is a library out there to fill the gap.

Windows Phone 7 Live Tile Schedules – How to execute instant Live Tile updates

comments
If you’ve worked with Windows Phone 7 Live Tiles, you may have noticed a bit of a hole in the platform SDK’s functionality – the inability to programmatically update the current running applications tile without the push coming from a remote webserver. The purpose of this post is to show you that this is not the end of the world, and there is a way around this. 

Replacing query string elements in c# .Net and JavaScript

comments
While writing list navigation and search features in websites today there is a constant need to find/replace and play with query string elements, so that you can easily manipulate these mystical items while you’re carrying them around in your website’s URLs. I have a few little methods I’ve used over the years and carry with me project to project, and this post is putting them on the record for easy access later.

Required CheckBox validation in ASP.Net MVC 2 onwards

comments
Having forms with checkboxes that require users to check them to be valid is a pretty common phenomenon on the internet today, however when thinking about this in terms of ASP.Net MVC it can not always be obvious what the best approach to take is. Thankfully the ASP.Net MVC team gave us the support to create a really simple solution when they added inheritable validation classes to the framework.

Make your XML strongly-typed: Because you can, and its easy

comments
Earlier in the week i posted a Twitter post commenting on how if your not using the XMLSerializer class to you advantage, well, as Scott Hanselman puts it now and then: Your doing it wrong. I use the XML Serializer classes on a daily basis to refer to my XML in a strongly typed manner and often wonder why i see people go to so much effort in creating hard to maintain code just to get data from or send it to an XML file.

How to fake Optional Parameters in c# 2.0

comments
With the launch of .Net 4.0 there have been a lot of excitement about some of the new features, Optional parameters being one of these. What a lot of people don’t realised it that with a bit of leg work you can pull this off with c# 2.0 – so those of you unable to deploy to a machine running .Net 4.0 can still join the party.

The black arts of custom Type conversion in c#

comments
One of the little used features of c#, is user written implicit and explicit type conversion. Put simply: sometimes you have a object (custom or built-in .Net framework) and want to convert it to another type of object. While you can easily write left to right style code to accomplish this every time, there is a lot cleaner way of doing this by empowering your objects to cast themselves as another type.

Twitterify your strings using c# regex

comments
So you’ve set up a twitter feed on your site – sweet. Now all your peeps can see how excited you are about the new limited edition Whitney Houston EP you’ve been listening to. But then you post a link – or a reply to a fellow twitterati member and those handy auto links you’ve become so used to aren’t there. Bummer duuude – lets fix that.

How to use the Not-so-new MailSettingsSectionGroup

comments
Today i came across something that from my day-to-day coding i have noticed a lot of my fellow coders at work/play have let slide on their path to .Net Mecca – using the MailSettingsSectionGroup section of the web.config to specify both SMTP server host details as well as they other properties such as user/pass credentials in a central, single, easy to use manner. So I'll take this opportunity to make it as easy as possible for you to use.

C# Convert DataSet to CSV

comments
Today i found myself wanting to quickly export a dataset to CSV and i didn’t want to bloat of a library that does more than i need. The following method is the result of this need/want.

C# reading an open text file in less than 10 lines

comments
There are times when you want to read a text file that is in use – or as i have had many times, code you have recently execute hasn’t fully let go of the file when you go to read it – when you copy something to a directory and the AV scans it or any other times when you want a file’s contents but don't want to have to worry about locks.

SubSonic, SQLite, Sonic.exe and 64bit, oh my!

comments
Well this week i started work on my new development machine – a 64bit Windows 7 machine mmmm tasty. Everything has run perfectly smoothly until i hit one weird little issue. While attempting to generate a new data layer for a SQLite database using Subsonic i received nothing but errors – Another simple fix which I'll show you in this post.

Retrieving a Flickr Photo ID from a URL using RegEx

comments
While working on a recent Flickr/Google Maps mashup i needed to make it as simple for users to share their Flickr photos as possible. What is easier than simply asking them to enter the Flickr photo page URL? Using this I'll show you a simple way to use RegEx to retrieve the photo ID part of the URL using c# as well as a JavaScript RegEx version for your ASP.Net RegEx validators. Lets get to it!

Consuming an ASP.Net WebService with Jquery & JSON

comments
ASP.Net Script Services and Web Services are an incredibly powerful tool for providing rich dynamic sites using AJAX. As good as they are, there are times when you want to access them in alternate ways. Combine JQuery, JSON and ASP.Net Web Services and you have a combination that rivals the A Team – lets take a look.

Adding Windows Live Writer support to your Blog engine

comments
If there is one blogging related tool that I've come across lately that i think has been a game changer it would have to be Windows Live Writer. However some people are using either a custom written blog engine (like me) or are using a blog engine that doesn’t support Live Writer. If that is the case i will show you a simple way to integrate Windows Live Writer support into you blog with WebServices and the MetaWebLog API.

Sending encrypted e-mail with C#

comments
There are times when the invention that we all call E-mail just doesn’t cut it for sending information securely. It is because of this that in every case where information really needs to be sent securely E-mail is not usually the medium chosen to send it. As most developers know though there are times when you have to bite the unsecure E-mail bullet. I’ll show you a way to solve this conundrum and at the same time probably keep your current e-mail client.

Upgrading Umbraco from 3 to 4 – Not all smooth sailing

comments
If you have ever had to setup or manage an Umbraco installation you will know both the pleasure and the occasional pain that it can bring. Umbraco is part of the growing list of “oober cool” up and coming Dot Net CMS that are getting attention in the “get it up quick” world of marketing driven sites in the market place (Ford Australia for example). I recently had to upgrade a clients installation from 3.0.5 to 4.0.2.1 and the story that follows will hopefully help someone in a similar position so that they can revel in the same relief that I do currently.

Getting a full ASP.Net rendered page as a string

comments
So there i was looking for a simple solution to offer a preview function on a CMS for a client at work, when it hit me. Why try and replicate the content of the page in anyway (i could use a blank page and fill it in, i could carry values as a session and redirect to the front end view page. The reality is: I could do many different things. The real question comes down to “How would a Ninja do it”