First NxtGenUG meeting

First NxtGenUG meeting

Last Monday I attended my first user group meeting held by NxtGenUG in Coventry.  Wasn’t sure what to expect from the evening, however ended up being an enjoyable evening (beer, food and Testing UI – what more do you want?) and hopefully will be attending the next meeting on Security. I also got some swag in the form of a T-Shirt and WinFX toolkit.  

Basically, there was a 10 minute demo of the Atlas framework, some quick news announcements, food and then just over an hour presentation of Testing UIs which was interesting.

Not sure if I will be able to go to the meetings in Birmingham, but if there is one which catches my eye I’m sure I will make the effort.

If anyone wants more information then visit http://www.nxtgenug.net

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).