A NullReferenceException is thrown unexpectedly, under certain circumstances, when the class we attempt to mock contains constructors that have unmanaged pointers as parameters.
MyClass^ fakeMyClass = Isolate::Fake->Instance<MyClass>(); // throws unexpected NullReferenceException
If the managed class we are attempting to mock contains a public default constructor, no exception is thrown. But, in the absence of a public default constructor, we see inconsistent behavior. In our header file, if the last listed constructor's parameters contain any unmanaged pointers, a NullReferenceException is thrown. If we reorder the constructors in the header file so that the last one listed does not contain any unmanaged pointers, no exception is thrown.
Is this a bug? Certainly we could proceed by simply requiring all of our classes within the assembly to have public default constructors, but we would prefer not to do this. (And, any sort of conditional compilation is far from optimal.)