An NH Prof Bug Story: Why integration is tricky

time to read 2 min | 216 words

Today I found out that NH Prof doesn't work with ASP.Net MVC applications. If you would have asked me, I would have sworn any oath you care to name that it would. And even after seeing the problem with my own eyes, it too me a while to track it down.

To make a long story short. Somewhere deep in the bowels of NH Prof, I made the assumption that a method is always contained in a type. I am pretty familiar with the way that the CLR works, and it seemed like a pretty reasonable assumption to make. In fact, I didn't even realize that I was making it.

Enter the ASP.Net MVC code, which generate method on the flies in order to do some of its work (haven't dug in, but I am willing to be that this is done using Expression.Compile() ). Methods that are generated on the fly using LCG do not have to be in a type. They can be just free floating methods. When my code encountered that, it choked and died horribly. Leading to a "there is no way this is happening" session.

The bug is fixed now, of course, but it is a good story, and a cautionary one about assumptions that you are not even aware that you are making.