Monday, December 22, 2008

WPF DataGrid CheckBox Column Editing

We’re using the WPFToolkit on my current project, specifically the DataGrid control. We needed to programmatically add some CheckBox Columns to the layout, and it was pretty straight-forward.

The only issue we had was the cells required two clicks to flip the checked state of these cells. I spent a few minutes searching through the Discussions for the project and stumbled across this gem: Single Click Editing – worked like a charm (and now QA should be able to resolve the bug that was generated around this quirky functionality).

FileNotFoundException: Could not load file or assembly 'Microsoft.TeamFoundation.Client....

At the start of my current project, I decided it was time to rewrite my TFS Build Utility against the 2008 API/SDK.

I didn’t get get very far before I started to see a “System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.TeamFoundation.Client, Version=9.0.0.0” message whenever I ran my code.

More strange, the app would bring up my main form just fine, but as soon as it hit the constructor of my presenter, I’d get that error. The first line in my constructor was a call to a method where I’d be initializing my TeamFoundationServer object, but I never even got to that line, the exception happened as soon as I stepped into the first line of the constructor.

After a bit of Google searching, I eventually landed on Omar Villarreal's post on using the TFS API in a 64-bit environment – which is what I was doing, and the solution: setting the Platform Target property for my project to x86, instead of “Any CPU” as is set by default in Visual Studio.

Saturday, December 06, 2008

TeamBuild Error Running UnitTests with WPF Objects

I’m just wrapping up sprint 1 of my latest project and as such have been taking care of some infrastructure type tasks. We’re using TFS2008 for our SCM/CI stuff, so I created a new build definition for our main project (WPF/Linq to SQL). We had about a dozen unit tests at this point, all of which we green on our machines (Works on my machine), but once I fired off my build on the CI box, two of the tests failed with the following error:

Test method TestAssembly.TestClass.MyTest threw exception: System.Windows.Markup.XamlParseException: 'StackPanel' object cannot be added to 'Grid'. The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018) Error at object 'System.Windows.Controls.StackPanel' in markup file 'TestApp.UserInterface;component/view/myview.xaml'. ---> System.Runtime.InteropServices.COMException: The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018).

The two tests that failed happened to be the two that created an instance of a WPF Window, which no other tests in the suite did, so at least we had some clues to Google with. It didn’t take long to stumble across this page: MS Forums: .NET 3.5 SP1 breaks use of WPF under IIS.

Although we weren’t doing anything with IIS, the rest of the symptoms sounded exactly like what we were dealing with. We took the advice given in the first community comment that indicated we should run the executable in XP SP2 compatibility mode and applied that the the TFSBuildService executable. The next build succeeded and we were back to coding.

The good news is that MS intends to fix this issue with a future patch/service pack, but not until sometime next year, so for now, you’re stuck with forcing compatibility mode on your failing executables.

Thursday, December 04, 2008

Mocking the Unity Container

While trying to get some tests running for my current project (WPF, VS2008, C#, MSTest, RhinoMocks 3.5, Vista 64bit), I ran into an issue where I can’t mock out the Unity Container.

I was following the advice on Randy's Blog, but when I hit the line where I’m creating a stub of the IUnityContainer, the test blows up with the error below, and like others have mentioned, when in debug, the error doesn’t surface. Here’s the error I’m seeing:

Initialization method Test.Presenter.GivenPresenter.TestAnythingAndSeeItFail threw exception. System.BadImageFormatException: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B).

Seems I’m not the only one running into this error:

http://www.nabble.com/BadImageFormatException,-but-not-when-debugging-td18742529.html

http://groups.google.com/group/RhinoMocks/browse_thread/thread/b2235a13f920c616

Edit:

After a failed attempt to created a fake based on IUnityContainer, I ran across Roy Osherove’s post on creating an AutoMockingUnityContainer which worked perfectly for my test needs.

Wednesday, December 03, 2008

Installing eScrum 1.1 for TFS 2008

I just wanted to take a few moments to note some of the struggle points I encountered while installing the eScrum 1.1 template on my company’s TFS 2008 box. The environment is a single-server TFS2008 install on a Windows 2008 server and a separate Windows 2008 Server running a MOSS farm that will serve up the SharePoint bits for our TeamProjects.

One issue I had was that the configuration utility that launches at the end of the install didn’t seem to let me do anything – I would either get an exception window or an error that the “website installed unsuccessfully” (huh?).

I decided to just close the utility and dig through the eScrum_readme.rtf file to see if I could figure out what was up. This file is your best friend while you’re fumbling though the eScrum configuration.

Not seeing anything in particular about none of the configuration utility tools working, I relaunched the configuration utility as Administrator and this time succeeded in install the website, but not the SharePoint template.

Getting the eScrum Website working

I then referred back to the read-me document and followed the post-installation steps to configure the app-pool. The only confusing item there is that the example script command they show actually had the website ID in the sample, instead of “<website>” as the next step hints at how to locate, but no biggie, it was pretty clear what they meant. The shortcut for locating this on a Vista/Windows 2008 box is at the very bottom of the read-me.

When I then tried to browse the local site, I kept getting errors about the Session member in the httpModules section of the web.config being a duplicate, so I removed that entry and then received a new error (I forgot to write down the exact error unfortunately). However, this time, the webpage had a command that it indicated I should run from a command-window, and this command cleared up my issue and I had the website running.

Getting the SharePoint Template Uploaded

Our environment had an existing MOSS Farm that we wanted to utilize, so I ran the STSADM utility from the SharePoint box and added the eScrum_tfs2008.stp template. Quick and easy.

Uploading the eScrum Project Template for TFS

At this point, the last thing I had to do was upload the eScrum template to the TFS machine. I couldn’t get the Configuration Tool to upload this for me, so I had to do things manually. I ended up expanding the contents of eScrumProcessTemplate.zip into a folder and pointing to that in order to get the project template uploaded to my TFS server. The read-me indicated that I should have been able to do the upload from the zip file, but the upload manager wouldn’t enable the Upload button so I used the unzip then upload method.

Adding your project to the eScrum website project list

The last thing you’ll need to do in order to use the eScrum website with your project(s) is edit the eScrum UI’s web.config as outlined in the read-me. After that, you’re off and running.

Monday, December 01, 2008

I'm Back....

Ok, it's been a LONG while since I added anything to this blog, but I've decided to dust it off and start getting a bit more active with posting, so stay tuned.....