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
0 votes
I just downloaded a trial and tried to create a new unit test using it, but when I run the test I get a NullReferenceException in the constructor of the unit test *class* itself:

>   TypeMock.dll!e4.e4() + 0x65 bytes   
    [Native to Managed Transition]   
    [Managed to Native Transition]   
    TypeMock.dll!TypeMock.MockManager.f(System.Type A_0 = {Name = "P2_Session_Tests" FullName = "UnitTests.P2_Session_Tests"}) + 0x63 bytes   
    TypeMock.dll!ai.g(System.Type A_0 = {Name = "P2_Session_Tests" FullName = "UnitTests.P2_Session_Tests"}) + 0x2f bytes   
    TypeMock.dll!TypeMock.MockManager.IsTypeMocked(System.Type type = {Name = "P2_Session_Tests" FullName = "UnitTests.P2_Session_Tests"}) + 0x3c bytes   
    TypeMock.dll!TypeMock.MockManager.GetMocks(System.Type type = {Name = "P2_Session_Tests" FullName = "UnitTests.P2_Session_Tests"}) + 0x34 bytes   
    TypeMock.dll!TypeMock.MockManager.c(object A_0 = {UnitTests.P2_Session_Tests}) + 0x7d bytes   
    TypeMock.dll!TypeMock.MockManager.a(object A_0 = {UnitTests.P2_Session_Tests}) + 0x3e bytes   
    TypeMock.dll!TypeMock.MockManager.b(object A_0 = {UnitTests.P2_Session_Tests}) + 0x4d bytes   
    TypeMock.dll!TypeMock.MockManager.a(string A_0 = "UnitTests.P2_Session_Tests", string A_1 = ".ctor", object A_2 = {UnitTests.P2_Session_Tests}, object A_3 = null, bool A_4 = true, object[] A_5 = {object[0]}) + 0x26d bytes   
    TypeMock.dll!TypeMock.InternalMockManager.getReturn(object that = {UnitTests.P2_Session_Tests}, string typeName = "UnitTests.P2_Session_Tests", string methodName = ".ctor", object methodParameters = null, bool isInjected = true) + 0x60 bytes   
    UnitTests.dll!UnitTests.P2_Session_Tests.P2_Session_Tests() + 0x51 bytes   


For reference in the above call stack, "P2_Session_Tests" is the class name.

I couldn't reproduce this in a brand new project with no references, so the only thing that I could think of was that maybe it's something to do with one of my references. However, I commented out all code from my unit test project, except for the class definition and a single method and even removed all non-framework (or Typemock) references, but I still get the same error.
asked by tencntraze (640 points)

3 Answers

0 votes
I just realized that I had VS set to break on all exceptions, so that's why I saw this during my test. Perhaps this error is an indication of some additional underlying problem, but I can't really nail down what it is from my end.
answered by tencntraze (640 points)
0 votes
Can you post the code that caused this exception?
answered by dhelper (11.9k points)
0 votes
Looking at our code, I found a place we throw an exception and catch it immediately in the stack trace you sent. In case you are catching all first chance exceptions, this will cause the behavior you are witnessing.

Upon further investigation it seems like we can give up throwing that specific exception, so I'll send you an email with an installer that does not behave like that, and this fix will be a part of the next Isolator version.

Thanks!
Doron
Typemock Support
answered by doron (17.2k points)
...