This blog has moved, permanently, to http://software.safish.com.

Thursday, April 22, 2010

NCover and NUnit AppDomainUnloadedException

I lost a few chunks of hair this morning. I needed to set up some kind of code coverage so I could prove to a client that our unit tests were actually doing what we said they were doing. I chose NCover as I had used it a few years ago - unfortunately I had to opt for the old, free community edition but maybe one day we'll be able to upgrade to the commercial version.

Anyway, getting ncover wasn't a big deal, I added the following section to the ccnet.config file for our project:
  
<exec>
 <executable>C:\Program Files\NCover\NCover.Console.exe</executable>
 <baseDirectory>C:\Builds\myproject\Source</baseDirectory>
 <buildArgs>"C:\Program Files\NUnit 2.5.2\bin\net-2.0\nunit-console-x86.exe" MyProjectUnitTests.nunit /xml:..\Artifacts\nunit.xml //x ..\Artifacts\ncover.xml //a Assembly.1;Assembly.2;Assembly.3</buildArgs>
 <buildTimeoutSeconds>360</buildTimeoutSeconds>
</exec>

This worked first shot. The unit tests ran, and the code in the assemblies I'd defined was analysed and added to the CruiseControl report (make sure you include the output xml files in your publisher/merge section too). All fine and well, except now my builds were failing. Looking at the logs, the unit tests were ALL passing, everything was fine, except there was an unhandled AppDomain exception being raised by NUnit. Running this on my machine didn't produce the same result - it was only happening on the build server. The exact exception message was:

System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.


It turns out, this is strange bug in NUnit 2.5.2, and as of now, there is no fix. Fortunately, this doesn't happen with version 2.4.7 - so for this project all I did was point to a different version of NUnit, and the errors went away. The older version does seem siginificantly slower than version 2.5.2 so it's not optimal, but until a newer version comes out with a fix, it's good enough for me.

Tuesday, March 30, 2010

Online Favicon Creation

Need a favicon for your site? Look no further than http://www.favicon.cc/.

Nice!

Wednesday, March 10, 2010

FFMPeg and the XBox 360

I've got a pile of old MPEGs on my PC from an old Sony camcorder of mine, that I wanted to play on my XBox 360. My XBox isn't connected to my home network, and I wanted to be able to convert the mpegs into something the XBox could read from an external drive.

I've been using Handbrake to do conversions, and it works. Handbrake is an excellent piece of software, but it isn't quite what I need, as I wanted to do batch conversions and the HandbrakeCLI is a little clunky and too slow for what I want.

I've been trying for ages to convert the files to .mp4 with ffmpeg, but the damn things just wouldn't play. I finally worked it out today. The mpegs have 5 channel Dolby audio - the XBox 360 doesn't support that. All I needed to do was restrict the audion channels to 2 on the output, and it worked! I haven't seen this anywhere on the web, so here goes:
ffmpeg.exe -i input.mpg -sameq -ac 2 -aspect 16:9 output.mp4

The -sameq tag forces the quality to be the same as the source. The -aspect is required for my files as the mpegs had a strange 2.34 aspect on them that made the resulting video play in a stretched mode (no idea why). The -ac 2 was the piece I was missing - this restricts the audio channels to 2, and my mp4 files now work on my XBox (which, incidentally, has the optional media pack applied). So now, I can just batch convert all my files to .mp4 using FFMPeg, which is REALLY fast, and I'm done.

Friday, February 26, 2010

NServiceBus error "Parameter name: meth"

It's been a while since I used NServiceBus and I got this annoyingly cryptic error message this morning:

Value cannot be null.
Parameter name: meth


I finally found this post about it and it's actually a fairly obvious mistake - I had added property without a setter on one of the objects that needed to be serialized as part of my message. The error message was unfortunately cryptic enough for me to take a while to find it. I thought I'd post this on here for my own future reference.

Friday, February 19, 2010

HTTP Pre-Authentication

Rick Strahl posted this excellent article on pre-authenticating HTTP requests - this is something that's caught me in the past but he explains the whole concept so well here I thought this was worth noting for my own future reference.

Friday, January 29, 2010

SQL Server: Updating varbinary fields

I'm working on a development database with a lot of varbinary fields - these are great once you have your admin screens but they're a pain in the initial development phase when there is no GUI for loading data. This little T-SQL snippet can be used to update varbinary fields - or adapt it to insert new data into varbinary fields.

update [schema].[table] set Column = (
 SELECT * 
        FROM OPENROWSET(BULK N'E:\Share\Temp\myfile.jpg', SINGLE_BLOB) AS BinaryFile
)

Friday, January 22, 2010

Page LifeCycle Events Listed

Joe Stagner posted this useful list of the entire ASP.NET page lifecycle events as they occur, in order.

Now if only you could get people to actually use these things correctly....