• CodeCampSA 2009

    According to an email from ADNUG’s Peter Griffith, Adelaide’s CodeCampSA 2009 will be held on July 18-19th. As in previous years, it will be at UniSA.

    I’ve offered to do a talk about Pex. I wouldn’t be surprised to see WPF guru Nigel popping up on the speaker list, and I’ve encouraged Ben and Timothy to think about whether they’d be interested in speaking too.

    I still think having a CodeCampSA website would be a great help for promoting the event too.

  • When PreRelease really means Release

    Once upon a time, I’d installed the 180-day trial version of SQL Server 2008, and prior to that I’d been running the last CTP.

    The expiry time was fast approaching, and I also needed to install the Integration Services components so I figured it might be time to uninstall the trial version and install the proper licensed one instead. The main reason I’d been putting this off was I knew it was going to take a few hours of uninstall/reinstall.

    So I uninstalled everything in Add/Remove Programs that looked vaguely related to SQL Server, rebooted, then installed a fresh version….

    Only to see “10.0.1600.22 ((SQL_PreRelease).080709-1414 )” in the About box of SQL Server Management Studio.

    Hmm.. In desperation I then uninstalled everything vaguely related to Visual Studio 2008, and then tried again…

    Same result!

    It was only then that I found this post in which I discovered that no, SQL_PreRelease really means RTM!

    Oh well, I guess it means my Visual Studio and SQL installs are fresher, but a bit of a pain nonetheless.

  • "Parameter count mismatch" calling Resolve<T>()

    I was seeing this exception being thrown in some code recently:

    System.Reflection.TargetParameterCountException: Parameter count mismatch. at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) at Castle.Core.ReflectionBasedDictionaryAdapter..ctor(Object target) at Castle.MicroKernel.DefaultKernel.Resolve[T](Object argumentsAsAnonymousType)

    The original source line was something like this:

    IDictionary<string, object> args = new Dictionary<string, object>(); args.Add( “paramName”, “value” );

    _kernel.Resolve( args );

    That all looks fine, and let’s assume the Something class has indeed a constructor with a string parameter named ‘paramName’. So why isn’t it working?

    I should have noticed the clue[1] in the stack trace, but was sure I had identical code elsewhere that was working correctly, so it had me stumped. It was only after taking a break from the code, then playing around with a very simple test project that I realised that while there is a method Resolve(IDictionary), that’s not the one that was being called here. Why? Because instead of using [var](http://msdn.microsoft.com/en-us/library/bb383973.aspx), I’d declared the variable to be an [IDictionary](http://msdn.microsoft.com/en-us/library/s4ys34ea.aspx)<string, object> – and surprisingly that interface does not imply you implement [IDictionary](http://msdn.microsoft.com/en-us/library/system.collections.idictionary.aspx) (the non-generic version).

    When I went back and checked other instances of the code that were working, sure enough I was using var and because Dictionary<> does implement both IDictionary<> and IDictionary it was working as expected.

    [1] The clue was the type and parameter name for Resolve - “Object argumentsAsAnonymousType” is obviously not the same as IDictionary!