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

In a VB test project in Visual Studio 2013 Update 5 on Windows 10, previously passing tests coded using the TypeMock VB syntax ("Using TheseCalls.WillReturn(1)...") throw a TypeLoadException with the following message:

System.TypeLoadException: Could not load type 'TypeMock.ArrangeActAssert.AAAScopes.VBRecordScope' from assembly 'TypeMock, Version=, Culture=neutral, PublicKeyToken=3dae460033b8d8e2

I have tested this in several configurations and have a minimal test solution that demonstrates the issue if you want it.  I have tried 3 different cases in three separate test projects, all inside a VB solution:

CASE 1 - VB all the way

The test project is VB and has references to TypeMock and Typemock.Isolator.VisualBasic.  The test is coded in VB TypeMock syntax.  The test fails with the TypeLoadException noted above. It is not discovered or run by TypeMock Test Navigator.

(Note: Adding a reference to Typemock.ArrangeActAssert this test project does not help.)

CASE 2 - VB and C# hybrid

The test project is VB and has references to TypeMock and Typemock.ArrangeActAssert.  The test is coded in C# TypeMock syntax ("Isolate.WhenCalled(Function() TypeMockTesting.TestClass.ReturnTwo()).WillReturn(1)"). The test passes but is not discovered or run by the TypeMock Test Navigator.

CASE 3 - C# all the way

The test project is C# and has references to TypeMock and Typemock.ArrangeActAssert.  The test is coded in C# TypeMock syntax.  The test passes and is also discovered and run by the TypeMock Test Navigator.


VB syntax used in VB test project:

        Using TheseCalls.WillReturn(1)
        End Using

C# syntax used in both VB-hybrid and C# test projects:

       Isolate.WhenCalled(Function() TypeMockTesting.TestClass.ReturnTwo()).WillReturn(1)


The MS Test Explorer gives some stack info when the test fails. For what it's worth, here it is:

Result StackTrace:    
at Typemock.Isolator.VisualBasic.CallsToLambdaConverter..ctor()
   at Typemock.Isolator.VisualBasic.CallsToLambdaConverter..ctor(Boolean useExactArguments)
   at Typemock.Isolator.VisualBasic.ReturnValueRecorder..ctor(Object value, Boolean exactArguments)
   at Typemock.Isolator.VisualBasic.TheseCallsInstance.WillReturn(Object value)
   at Typemock.Isolator.VisualBasic.TheseCalls.WillReturn(Object value)
   at UnitTestProjectVB.UnitTestVB.TestMethodUsingVBSyntax() in C:UsersDaviddocumentsisual studio 2013ProjectsTypeMockTestingUnitTestProjectVBUnitTestVB.vb:line 11



asked by DavidShannon (1.1k points)
edited by DavidShannon

2 Answers

0 votes
Hi David,

Thank you for the input.

I advise you to reference Typemock.ArrangeActAssert instead of VB DLL as it supports lambda expressions that weren't available in VB when this API was developed (thats the reason we have Typemock.Isolator.VisualBasic).

Case 3: Typemock runner currently supports only C# syntax. You can benefit from using the smart runner If writing your tests in C# is possible for you.

We're looking into case 1. I'll update here when it's fixed.
answered by alex (17k points)
Hi alex,

Thanks for the reply.  Your suggestion that I use Typemock.ArrangeActAssert instead of VB DLL (essentially following CASE 2) is a good one for future tests, but I already have many, many tests written using the VB syntax. I really don't want to rewrite them if I can avoid it.

I understand the C# limitation on CASE 3 and it really isn't a problem.  I generally use the DevEx test runner (out of long habit) and what you never had you never miss.

I really hope a solution for CASE 1 is possible. Otherwise my test suite will be a bear to convert.

Finally, the question at appears to be related to mine, if that helps any.
0 votes

We released new version of Typemock Isolator today.

You can download it from here, It should solve your issue.

Let us know if it helps.

answered by Bar (3.3k points)