So, good news: I found and fix0r3d the code that broke NUnit.
As you may have guessed, NUnit wasn't broken. I was.
The code I thought I was working perfectly via debugger/VS.NET _WAS_ indeed working perfectly. I'd reflect over an assembly, instantiate a given type, invoke a method, and throw an exception PERFECTLY. Only I was reflecting and instantiating in my calling context (i.e. in my local AppDomain).
NUnit was barfing on me because the exception I was throwing was not correctly serializable. That's all.
How did I make it serializable Simple: decorate the exception with the [Serializable] attribute, and provide a default constructor that supports serialization. (NO THANKS to MSDN docs... they don't mention this in the SLIGHTEST.)
[Serializable]
public class BreakingException : Exception
{
public BreakingException () : base() {}
public BreakingException(SerializationInfo info,
StreamingContext context) : base(info,context) {}
}
Once I did that, all my problems went away, obviously. NUnit, and my remoting app, were then able to correctly handle serialization of my custom exceptions.




Comments