Category Archives: Visual Studio

How to create a Custom Debug Visualizer in Visual Studio

In this screencast, I talk through the process of creating a simple custom debug visualizer to view a System.Drawing.Image image.

Essentially, the visualizer is a class library that references the Microsoft.VisualStudio.DebuggerVisualizers and System.Windows.Forms assemblies. The project has a class, ImageVisualizer, that inherits the .NET framework DialogDebuggerVisualizer class, and overrides its Show method:

class ImageVisualizer : DialogDebuggerVisualizer
{
    protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
    {
        Image image = (Image)objectProvider.GetObject();
        ImageForm form = new ImageForm { DebugImage = image };
        windowService.ShowDialog(form);
    }
}

This converts the variable that’s being debugged to an Image type using the objectProvider parameter’s GetObject method call. This is then assigned to the dialog’s DebugImage property, and the dialog is shown using the windowService parameter’s ShowDialog method.

The actual dialog is very simple indeed, comprising of just a PictureBox to show the image, and a close button to, well, close the dialog.

public Image DebugImage
{
    set
    {
        this.pictureBoxImage.Image = value;
        this.pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom;
    }
    get
    {
        return this.pictureBoxImage.Image;
    }
}

The dialog class’ DebugImage property simply assigns the picture box’s Image property and zooms. I kept things simple for the screencast, but there’s no reason why the dialog couldn’t be extended to show other image properties such as image location, image type, and dimensions.

To use the visualizer, simply build the project and copy the dll to the Visualizers directory, which on my machine is:

C:Program Files (x86)Microsoft Visual Studio 10.0Common7PackagesDebuggerVisualizers

This particular path relates specifically to my machine, since I’m running 64 bit windows, and Visual Studio 10. Once the dll has been copied, it can be used on the next debug session. In the screencast, I use a simple console program example that loads an image from file. Clicking on the magnifying glass opens up the visualizer’s dialog, and the image can be seen.

Getting started with googletest – the Google C++ Testing Framework

So, I’ve just recorded a second screencast at screenr, this time about googletest – the Google C++ Testing Framework. I had a couple of issues getting things up and running so I thought it might be beneficial to show I got going.

I’ve been more used to unit testing in a C# environment, particularly NUnit and MS Unit, so googletest was a fresh look at unit testing for C++. Note that the screenr title is incorrect, it should read ‘Getting started with googletest – the Google C++ Testing Framework :)

5 things you may not know about ASP.NET

Since its release in early 2002, Microsoft’s ASP.NET platform has gone from strength to strength. Despite its strong uptake from Microsoft-centric software houses, there may be a few people who have hesitated in adopting ASP.NET for their web development platform. Here I present some things you might not know about ASP.NET. Perhaps it’ll encourage you to take a look at it.

Cost

There once was a time when the standard IDE for developing ASP.NET apps, Visual Studio, was prohibitively expensive for the average Joe. In late 2007, Microsoft released its first versions of ‘Express’ software, aimed at students and hobbyists. Though Express incarnations have fewer features than their full version cousins, they do offer the possibility of exploring ASP.NET. The Microsoft website offers a download page for Visual Web Developer 2008 Express Edition. An express version of SQL Server is also available, and can be downloaded from the SQL Server 2008 download page.

MVC Support

The MVC pattern is an established and well-recognised way of building web applications, and is familiar to RoR, Java and PHP developers. For many years, MVC was not available as a standard approach to developing ASP.NET websites, but Microsoft has recognised the deficiency and have (at the time of writing) released version 1.0 Release Candidate of ASP.NET MVC. The release has had a mixed response from the ASP.NET community, many of whom are used to the traditional code-behind model. Despite the inevitable squabbles as to which way is best, many have welcomed the MVC approach for its separation of concerns and finer control over JavaScript and markup. To find out more about the release candidate, head over to Scott Guthrie’s blog post.

Learning Resources

A big advantage for anybody learning a new technology is the wealth of learning material that is available. Although you can rely on a large number of books, the ASP.NET learn website contains many videos on both traditional and MVC ASP.NET as well as data access.

Intrinsic jQuery Support

The lightweight open source JavaScript library that’s taken the web by storm is now fully supported by Microsoft. As well as full intellisense support in Visual Studio, Microsoft will be using the library as-is, without forking or changing the code from the main jQuery branch. What’s more, Microsoft will be using jQuery as a basis for future ASP.NET and ASP.NET AJAX features. I feel this counters the argument of Microsoft not supporting open-source software.

Career Prospects

Microsoft’s ubiquity means that learning ASP.NET and supporting technologies will do no harm to your career prospects. .NET skills are ranked as some of the most in-demand in the UK.

October web round-up

October Web Roundup

It’s been a busy old month, and with so much time working, I’m going to share some of the things that have interested me during October.

Windows 7 Desktop Improvements

With hardware compatability issues and a reluctance from users and computer manufacturers to adopt it, Vista hasn’t perhaps been the success that Microsoft had hoped. The next version of Windows gets a preview over at channel9. There’s quite a lot of verbal fluff at the beginning, but forward through and you’ll get an idea of some of the features that’ll be present in the next version.

ASP.NET MVC Beta

Many of the great frameworks, such as CodeIgniter and Ruby on Rails use a MVC architecture, and it’s a concept that many web developers are familiar with. Maybe not so developers who have exclusively used ASP.NET for their development. Since the introduction of Visual Web Developer Express, developing has become very attractive for hobby developers wishing to get to grips with ASP.NET. I think the development of ASP.NET MVC will encourage those familiar with the pattern to give it a go. Scott Guthrie describes the beta release on his blog.

Microsoft to ship jQuery with future versions of Visual Studio

I’ve been using jQuery alongside ASP.NET for several months now, and find it to be an excellent JavaScript library. I was quite shocked that Microsoft will be distributing it with future versions of Visual Studio (including express versions), providing support for it, and providing intellisense support for it. Good on ‘em!

Google releases Google Earth for iPhone/iPod Touch

I’d definitely recommend a download of free app Google Earth – well worth taking a look.

For more information, head over to the Google Earth on the iPhone page.

Google Android Phone

Following the launch of Chrome , Google is pressing ahead with Mobile Device Platform Android. Now the first handset, the T-Mobile G1 has hit the market. It’s certainly no looker, but Google is a company that has the expertise to change the mobile market, and I’ll be keeping an eye on things, that’s for sure. For now though, I’ll keep my iPhone.

No opera for iPhone

Well well, a version of Opera has been developed for the iPhone, but Apple has refused to add it to their App Store, stating that it is too similar to Safari. So, I won’t be holding my breath for a version of Firefox, either. John Gruber offers his opinion over at Daring Fireball.