chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
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.)
asked by navdan (720 points)

2 Answers

0 votes
Hi,

Thanks for submitting the problem. This looks like a bug.
Can you please send a small repro to our support: support at typemock.com ?
answered by ohad (35.4k points)
0 votes
Thanks, ohad. Just an FYI, per your request, I sent an e-mail containing a sample project to the support e-mail you provided on Friday (2/25/2011) at about 3:40 PM EST. I look forward to your reply!
answered by navdan (720 points)
...