Imagine Cup 2006 Results :: Imagine Cup 2007 Theme

The finals of the Imagine Cup 2006 where today and I just saw on Channel9 that Italy won!! Brazil came second, with Norway coming third. Congratulations to Italy and all the other entries….
http://channel9.msdn.com/ShowPost.aspx?PostID=224744

Have a look at there design, and the other finalists here:
http://www.imaginecup.com/finals/Software_Design.htm

Sadly I never got a team together for 2006. However 2007 competition title has already been announced.  The theme is: “Imagine a world where technology enables education for all” (http://blogs.msdn.com/somasegar/archive/2006/08/11/695473.aspx).  So start thinking about some ideas, and who you want to be in your team.  

If anyone wants to drop me an email regarding this then please feel free @ Ben {at} Ben Hall {dot} me {dot} uk.

Hopefully I will be entering this year, all being well I will be a Microsoft Student Partner and I will have more contacts/developer friends to form a team with. Just getting to the UK finals would be a excellent achievement.

AppDomain.CurrentDomain.AssemblyResolve :: Different Assembly version numbers causes casting to fail

Few days ago, I came across a problem with the MbUnit code that I was looking over to get an idea of the architecture.

The problem was that when the reference to the mbunit.framework in the project you are testing is different that the reference in the exe the application would crash with a random error message.

The section of code which causes a problem was when it tried to cast a type from one assembly into a type from another assembly. Due to them having different version numbers, they are treated as completely different types and cannot be cast between the two. This happened since we started to sign the assembly, as before, unsigned assemblies do not worry about the version number and treat everything as the same.

After a few hours, I found a cool event on the AppDomain object called AssemblyResolve. When a different assembly is loaded in the application with a different version type, the event is fired and calls this section of code:

private Assembly AssemblyResolveHandler(object sender,ResolveEventArgs e)

{
try
{
string[] assemblyDetail = e.Name.Split(‘,’);
string assemblyBasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Assembly assembly = Assembly.LoadFrom(assemblyBasePath + @”” + assemblyDetail[0] + “.dll”);
return assembly;
}
catch (Exception ex)
{
throw new ApplicationException(“Failed resolving assembly”, ex);
}
}

This takes in the assembly Full Name (e), and loads the assembly name from file making sure that the latest assembly is always loaded. This seemed to have solved the problem with MbUnit, as it protects against people having old references in there project.

Just thought it was a good code snippet.

WWDC 2006: Quick round up

So, no new MacBook for me, lot of students on the forums aren’t happy as like me was all hoping for one to return/go to Uni with.  However, I still live in hope that they will be available before the end of September.

Quick roundup.
New MacPro replaces PowerMac.  Runs on Quad Xeon processors.
New XServe machines.  Looking very sweet, nice little 1U machines at not a bad price. Would love to get my hands on one of these bad boys…
Leopard Preview (top-secret features hidden and not being shown due to copycats…)
Watch demos here: http://www.apple.com/macosx/leopard/

This WWDC has got me interested in developing on a Mac again; I have my cocoa book in my pile next to me. One day, I will read it!

Creating objects dynamically with C# 2.0

Creating objects dynamically with C# 2.0

So I have been playing with some code this morning on how to create objects in the assembly dynamically just based on their class name.

Basically, I created a console application with an interface and three subclasses. The application will print out a list of object names they could create, and asks the user to select which one to create.  Based on the user input, the name is passed into the method below and returns an object of type IPayment (the interface).  The console application then calls a method on the object which returns its name and prints it out to the console.  Simple but effective.

This is the most important method, which does most of the work.

        public static IPayment GetPaymentObject(string className)
        {
            //Get the current assembly object
            Assembly assembly = Assembly.GetExecutingAssembly();

            //Get the name of the assembly (this will include the public token and version number
            AssemblyName assemblyName = assembly.GetName();

            //Use just the name concat to the class chosen to get the type of the object
            Type t = assembly.GetType(assemblyName.Name + “.” + className);

            //Create the object, cast it and return it to the caller
            return (IPayment)Activator.CreateInstance(t);
        }

Works well as a simple example, and demonstrates the important concepts.

Download the full code here:
http://blog.benhall.me.uk/Code/DynamicFactory/Program.cs.txt

Let me know what you think.

WWDC 2006: Inside Apple on Blu-ray, MacPro and Apple’s media center strategy. What to expect, and not to expect, at WWDC

Found this to be an interesting read, it is about upcoming Apple products and WWDC.  Lot of talk about WWDC online at the moment.

http://www.dvdnewsroom.com/news/breaking-inside-apple-on-blu-ray-macpro-and-apple%e2%80%99s-media-center-strategy-what-to-expect-and-not-to-expect-at-wwdc/

Most interesting bit for me personally:


A. Any truth to an Apple Tablet?
Q. Prototyped of course. Price is the issue, without cannibalizing the MacBook. The ideal price is $599. But it’d cost too much to make. Take an average guy visiting an Apple Store at his local mall. If he had to choose between a $1099 MacBook or tablet, the MacBook would win. A tablet is too niche at that price – only the Apple elite would buy. We’re becoming generalists and the Apple Store supports that strategy. Generalists with superior products.

Like a lot of other people, I would love to see an Apple Tablet, but I wouldn’t pay $1099 for it (ok, I would, but I wouldn’t like to).

Progress Report

I haven’t posted anything in a while, so I thought I would post an update on what’s going on.

  • Finished reading GTD. Interesting book, with a lot of points I wish I knew earlier. I am following some of his ideas and approaches but difficult as I don’t actually have that much to do at the moment apart from Read and Code (the difficult life of a student! ()
  • Reading Craig Larman’s Applying UML and Patterns book at the moment.  Very good read, some I already knew, some of it is new to me.  Giving me a nice firm foundation for next year which is good.  I would recommend this book to anyone who wants to know more about OO design.  Check out Computer Manuals if you want to purchase it (like at the side).
  • Been doing some work with the TFS Verison Tree Browser over at CodePlex recently ( http://www.codeplex.com/Wiki/View.aspx?ProjectName=TFSVTreeBrowse ) which has been interesting.  Coming from a Visual SourceSafe source control, this is new to me, but one I am looking forward to getting started in.
  • I have also been having a chat this morning with Andrew Stopford (seems a very nice guy, his blog is http://weblogs.asp.net/astopford) from the MBUnit team about helping with the development of the software.  Downloaded the source code this morning, so will definitely have a look at that this afternoon.  In case you don’t mind, MBUnit is a testing framework like NUnit with more bells and whistles, a topic I have a keen interested in at the moment.
  • Girlfriend came to see me for a few days, loved seeing her again (meet at Uni, she lives in London – I don’t). Had a really nice few days, went to see Cars which was cool (nice work Mr S. Jobs), the visual effects where amazing.
  • Finally, WWDC 2006 is almost here!!  This is the Apple Developer conference, keynote is on Monday. I can’t wait to see what is coming up, I love apple, their ideas and products. Personally I am hoping they are going to announce the MacBook Pro Core Duo 2, think I would buy it straight away (get student discount) with 2Gb of ram, and dual boot with Windows for development.  Girlfriend would kill me, and so would my bank balance, but they are such a cool machine!

Can’t think of anything else to write at the moment. Cool dudes!