Tuesday, December 29, 2009

Great Resource for Learning About Operating Systems

I happened to come across this page on the Berkeley University site which is a list of SWF and RealPlayer .ram files of lectures for the CS 162 Operating Systems and Systems Programming. I’m a big fan of learning about Windows internals and these lectures are great for helping me get more in depth information about the basics of operating systems and to brush up on stuff that I had forgotten since my computer science diploma days.

If you are using iTunes then there are loads of podcasts available from Berkeley, including CS 162. It looks like, starting from 2007, the CS 162 page does not have an MP3 available of each lecture, only the .swf file.

I highly suggest that you check these lectures out.

Wednesday, November 25, 2009

C# 4.0 – Learning About Dynamic Objects

When I first read about dynamic objects earlier this year, I must admit, I wasn’t sure how much use they would be to me other then, for example, COM programming. Now, considering that I currently do no COM development at all, this left me feeling that dynamic objects was never going to be useful in my arsenal of development tools. Well, that’s what I thought…until now.

Last week at the PDC 09 there was a session given about the new language features of C#/VB.NET in .NET 4.0, and from what I’ve watched so far, I’m excited at the possibilities. After watching the part about dynamic objects, I decided to have a go at a simple prototype app that shows how they can be used. Check out his class:

  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Dynamic;
  5. namespace Dynamic_Test
  6. {
  7.     class MyDynamicObject : DynamicObject
  8.     {
  9.         IEnumerable<string> _data;
  10.         IEnumerable<string> _headers;
  12.         public MyDynamicObject(IEnumerable<string> headers, IEnumerable<string> data)
  13.         {
  14.             this._headers = headers;
  15.             this._data = data;
  16.         }
  18.         public override bool TryGetMember(GetMemberBinder binder, out object result)
  19.         {
  20.             result = _data.ElementAt(_headers.ToList().FindIndex(s => s == binder.Name));
  22.             return true;
  23.         }
  24.     }
  25. }

Here I have a class that inherits from DynamicObject and overrides the TryGetMember. Doesn’t look like anything special yet, I’m just getting started. Now, here is my console app that makes use of the above class:

  1. using System;
  2. using System.Collections.Generic;
  4. namespace Dynamic_Test
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             List<string> headers = new List<string>();
  11.             List<string> data = new List<string>();
  13.             headers.Add("Test");
  14.             headers.Add("Another column");
  16.             data.Add("Value of item 1");
  17.             data.Add("Value of item 2");
  19.             dynamic line = new MyDynamicObject(headers, data);
  21.             Console.WriteLine(line.Test);
  22.         }
  23.     }
  24. }

Before I explain how the code works, have a look at line 21. Notice how I reference the ‘Test’ property on the object instance of MyDynamicObject – bear in mind that MyDynamicObject  doesn't have a ‘Test’ property, but the code still compiles without error. How so? Well, by declaring object ‘line’ to be of type dynamic, the compiler will treat this as something which will be sorted out at runtime – it’s not the compiler’s problem if 'property ‘Test’ doesn’t exist during a build. :)

When running the above code, you’ll see that the magic happens when you hit the line:


The code will enter the TryGetMember method of MyDynamicObject. In that method I have an expression that searches for the string ‘Test’ in the collection _headers (remember, it’s searching for ‘Test’ since that’s the dynamic property reference by ‘line.Test’). If the string is found in _headers, it’s index is returned to pick out the string in the collection _data. So in our example, the string ‘Test’ is found at element 0 of _headers, and element 0 of _data is ‘Value of item 1’, so that is the string which is displayed in the console window. Elementary stuff, but already very powerful.

In the PDC video, the speaker shows an example of code which reads the contents of a CSV file and by using dynamic objects he can reference dynamic properties to read values from the CSV via their columns. It’s worth checking out.

Wednesday, November 18, 2009

Possible Solution To Crackling Audio – Windows 7 Realtek

About a month ago I installed Windows 7 on my laptop, getting rid of the ol’ evil Vista which had been infecting it for almost 2 years. Once the Windows 7 setup was finished, I went through the usual routine of getting up to date drivers installed for devices such as video and audio. Now, as I’ve become aware, there have been countless people experiencing crappy audio from their laptops/desktops via Windows 7 due to Realtek’s drivers. I was one of those people and for the life of me I couldn’t get a Realtek driver that would fix the poor audio.

Finally I managed to get a driver that has fixed the problem – if you go to here you can download a zip which contains some drivers that were mention in this forum. At last, no more pops and crackles. :)

Sunday, November 15, 2009

‘Undocumented Windows 2000 Secrets’ Book Available Online

For those of you who enjoy reading about Windows internals, you can download a PDF version of the very popular ‘Undocumented Windows 2000 Secrets – A Programmer’s Cookbook’. This book has been out of print for a long time and, due to its popularity, used copies can cost and arm and a leg if you don’t shop around. So, save your pennies and navigate to here. There is a zip file with the contents of the companion CD that came with the book.

Happy reading!

Friday, October 23, 2009

Windows 7 Is Winning (Some Surprising) People Over


Yup, it’s Linus alright.

(OK, he did it for a joke – he didn’t buy a copy surprisingly :) )

Tuesday, October 20, 2009

.NET DLL’s Duplicated In Memory

For reading RSS feeds I use RSS Bandit which is just fine for my needs. However, I’ve often felt that RSS Bandit isn’t the most resource friendly application; on my Windows XP system with 1GB of RAM, it can feel a bit sluggish. Well this evening I thought I’d use VMMap from Sysinternals to see how much memory RSS Bandit is using – and in doing so I found something very odd.


The above view is a portion of the images section of RSS Bandit’s virtual memory space. Notice the duplicate DLL files loaded in memory, there are many other DLL duplications appearing, wasting a lot of memory. I counted about 28MB of memory was being wasted by duplicate DLL files. The most notable thing about this, is that all the DLL files are .NET DLL’s.

Now this actually rang a bell with me, since in the back of mind I thought I had read something about this on a forum. After some hunting around I found the original Sysinternals forum post where I had read about this duplication issue. It turns out that Microsoft have been notified about the problem and are looking into it.

Problem is that a fix won’t be coming anytime soon. If you read the last post for the Connect bug report, by Aarthi Ramamurthy, you’ll see that MS have anaylsed the problem and decided that it’s too large a change to do anything about it right now.

Sunday, October 18, 2009

TypeMock Isolator 5.4.2 Released.

Hot on the heels of version 5.3.5, Isolator 5.4.2 has just been released. The new feature of this release is Intellitest which is a tool to help developers create the arrange section for tests. (AAA – Arrange, Act, Assert). So how does this Intellitest work? Well there is some sample footage of it in action here and here. I was just trying it out now with a simple class library.

So I have an interface like so:

namespace ClassLibrary1
    public interface IPerson

string GetFirstName();

string GetLastName();


which is used by this class:

namespace ClassLibrary1
    public class Class1
        public string DoSomething(IPerson p)
            return string.Format("{0} {1}", p.GetFirstName(), p.GetLastName());
I go ahead and create a unit test project and start writing my test:

public void GetSomethingTest()
    Class1 target = new Class1();

The cool stuff happens once I put the caret in the method call for DoSomething() I get this window appear:


I can now choose to create a fake IPerson to pass to my DoSomething(), which Isolator takes care for me by automatically inserting the code needed to perform the faking:


This has great potential, by adding functionality that can speed up the creation of the arrange code for developers, I think TypeMock are adding another great asset to the Isolator feature list.

At the moment, Intellitest only works with interfaces, but classes will be supported soon. I can’t wait to see what’s in store when this feature matures. Though my only concern is that, with a recent increase in price for Isolator, that Intellitest doesn’t

  • Increase the cost of Isolator even more.
  • Becomes a separate product that you have to pay for.

Chances are one of the above options will become a reality. Personally I hope they choose the second option, since I’d rather pay for Isolator with the current feature set, and have the option to purchase Intellitest if I really wanted it.

Wednesday, September 23, 2009

Windows 7 Developer Boot Camp

If you want to get ahead with developing solutions for the latest version of Windows, then this sounds like a fantastic event in the making. I’m a big fan of Mark Russinovich and I also enjoyed watching the Channel 9 videos of Landy Wang (memory manager guru) and Arun Kishan (architect in the Windows kernel team) – and to have these guys make an appearance at the developer boot camp makes me wish I had the chance to go. Ah well, you win some, you loose some.

To any of you who are going, I hope you have a great time (I hope the sound of my gritted teeth didn’t come through there!).

Thursday, September 17, 2009

.NET Reflector 6 EAP Available!

For those of you who love using .NET Reflector, there is now an EAP of version 6 available here. Red Gate have done a ton of work in this version to allow you to step into .NET code using a .NET Reflector addin in Visual Studio. There is an example walkthrough of this listed in the above I link I gave. As I´m currently in Tenerife, I can´t test the addin,but I have downloaded version 6 to have a quick look. On the whole it still looks the same as version 5, so for this EAP the big news is the VS integration. I´m sure that Red Gate will had features to the stand alone Reflector program as well. Looking forward to the next release :)

Thursday, September 10, 2009

Telerik Release TFS Work Item Manager & TFS Project Dashboard

Just a quick mention of some new, and free, tools from Telerik for those of you who use Team Foundation Server as part of your development process. The new tools are applications that you can use to view things such as work items, iteration and sprint details (for those of you using the agile templates), progress information (number of items completed, those currently being worked on, etc). Doesn’t sound like anything special, but when you see the great UI which is presented to you (built with WPF), you’ll soon forget about using the boring team explorer tab in Visual Studio.

A video on the site shows you an introduction to the tools, which I’m going to install tomorrow if I can squeeze some time in.

Friday, July 31, 2009

Wow, Must Be One Hell Of A Long Path!


Monday, July 20, 2009

I've Added Ad Sense To My Blog

I’ll have to wait about 48hrs for adverts relating to software development to appear. In the meantime, for those of you viewing my blog, you lucky people can click on these beauties which were generously randomized for me:


Passed exam 70-536.

About a month ago I passed the TS: Microsoft .NET Framework - Application Development Foundation exam. I had been a bit lazy about taking this one, having bought the training kit about 2 years ago! (Yup, I bought the the first edition, which has about 3 Microsoft Knowledge Base articles devoted to it’s mistakes). Mistakes aside, I managed to pass the exam with the aid of that book, plus Programming Microsoft® Visual Basic® 2005: The Language which is an excellent tome. I highly recommend it, even though its targeted towards Visual Studio 2005, since the author goes into great depth on many subjects such as reflection, object oriented programming, threads, security.

Saturday, May 23, 2009

Trying Out VS 2010

I downloaded the VS Professional 2010 bits last night, as I’ve been looking forward to testing out the next version for a while. The new WPF code editor has got me very excited (yeah I know – sad :)) due to the new possibilities for writing some cool UI extensions, like those which can be found at the Visual Studio Gallery.

One of the first things I wanted to try out where the new Sub() based Lambda’s in VB, which was not available in the language for VS 2008, though Func() was. As I sat down to start a new console application, I was a bit disappointed. Here is the code I was working with at the time:

Public Sub Main() 
    Dim k As String() = { "F", "B", "C" }
End Sub

When I type the ‘(‘ character, VS started to churn a bit, think about it for a bit longer and then crash :( Humph. OK it’s a beta, so things like this are going to happen. Unfortunately it happens a lot for me. Even when creating a new class and instantiating it, the second I type a dot ‘.’ next to the variable name, I get a crash. Grrr.

Oh well. Hopefully by beta 2, things like this will have been ironed out. All in all, I’m really looking forward to VS 2010 since there is promised SharePoint support in the IDE (inside the server explorer, where you’ll be able to navigate SharePoint sites directly) and more SharePoint project templates. Cool. Having worked on many SharePoint projects, I can say that the development experience can prove frustrating at times.

Personally, it would be nice if they got rid of the need for SharePoint Designer and integrated everything into VS, giving users the option to use either for their SharePoint work. My reason for this request? SharePoint Designer is a heap of junk and I detest having to use it. But hey, that’s for another blog post…..