MSTest Runner gives "Exception has been thrown by the target of an invocation"
Asked by Roshan Fernandes:

I am using Windows Server 2012 R2, bamboo as windows service with administrator account. MSTest Runner was working fine (with .NET 4.7) until the latest Visual Studio 2017 update 15.8.3 on the server to support .NET 4.7.2.

Does anyone know how to fix the error? I can run tests successfully from Visual Studio 2017 IDE in the same server.

Error from MSTest.exe logs:

W, 2476, 1, 2018/09/07, 09:23:42.270, VWBUILD02\\MSTest.exe, TestType: #313, {ec4800e8-40e5-4ab3-8510-b8bf29b1904d}: Could not find string resource for name from 'Microsoft.VisualStudio.QualityTools.Tips.OrderedTest.Tip, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a:#313'

W, 2476, 1, 2018/09/07, 09:23:42.375, VWBUILD02\\MSTest.exe, EqtException: Exception has been thrown by the target of an invocation.

Complete Logs from MSTest.exe:

V, 2476, 1, 2018/09/07, 09:23:41.791, VWBUILD02\\MSTest.exe, Runner.Main: starting...  
V, 2476, 1, 2018/09/07, 09:23:41.933, VWBUILD02\\MSTest.exe, RegistryDetourHelper: InitiatePkgDefMerge Start  
V, 2476, 1, 2018/09/07, 09:23:42.030, VWBUILD02\\MSTest.exe, RegistryDetourHelper: VS private registry is initialized. Donot initiate pkgdef merge  
V, 2476, 1, 2018/09/07, 09:23:42.182, VWBUILD02\\MSTest.exe, Tmi:Tmi  
I, 2476, 1, 2018/09/07, 09:23:42.234, VWBUILD02\\MSTest.exe, New test type record: {13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b}  
V, 2476, 1, 2018/09/07, 09:23:42.239, VWBUILD02\\MSTest.exe, Test type {13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b}: Satellite DLL found OK  
I, 2476, 1, 2018/09/07, 09:23:42.250, VWBUILD02\\MSTest.exe, Test type {13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b}: TIP 'Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestTip, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Tip, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'  
W, 2476, 1, 2018/09/07, 09:23:42.259, VWBUILD02\\MSTest.exe, TestType: #212, {13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b}: Could not find string resource for name from 'Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Tip, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a:#212'  
V, 2476, 1, 2018/09/07, 09:23:42.259, VWBUILD02\\MSTest.exe, Test type {13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b}: assosiated with editor {00000000-0000-0000-0000-000000000000}  
I, 2476, 1, 2018/09/07, 09:23:42.261, VWBUILD02\\MSTest.exe, New test type record: {982b8c01-1a8a-48f5-b98a-67ee64bc8687}  
V, 2476, 1, 2018/09/07, 09:23:42.263, VWBUILD02\\MSTest.exe, Test type {982b8c01-1a8a-48f5-b98a-67ee64bc8687}: Satellite DLL found OK  
I, 2476, 1, 2018/09/07, 09:23:42.263, VWBUILD02\\MSTest.exe, Test type {982b8c01-1a8a-48f5-b98a-67ee64bc8687}: TIP 'Microsoft.VisualStudio.TestTools.TestTypes.Generic.GenericTestTip, Microsoft.VisualStudio.QualityTools.Tips.GenericTest.Tip, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'  
W, 2476, 1, 2018/09/07, 09:23:42.266, VWBUILD02\\MSTest.exe, TestType: #440, {982b8c01-1a8a-48f5-b98a-67ee64bc8687}: Could not find string resource for name from 'Microsoft.VisualStudio.QualityTools.Tips.GenericTest.Tip, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a:#440'  
V, 2476, 1, 2018/09/07, 09:23:42.266, VWBUILD02\\MSTest.exe, Test type {982b8c01-1a8a-48f5-b98a-67ee64bc8687}: assosiated with editor {c050a6af-a22f-b534-f966-d0cb9a7fff37}  
I, 2476, 1, 2018/09/07, 09:23:42.266, VWBUILD02\\MSTest.exe, New test type record: {ec4800e8-40e5-4ab3-8510-b8bf29b1904d}  
V, 2476, 1, 2018/09/07, 09:23:42.267, VWBUILD02\\MSTest.exe, Test type {ec4800e8-40e5-4ab3-8510-b8bf29b1904d}: Satellite DLL found OK  
I, 2476, 1, 2018/09/07, 09:23:42.267, VWBUILD02\\MSTest.exe, Test type {ec4800e8-40e5-4ab3-8510-b8bf29b1904d}: TIP 'Microsoft.VisualStudio.TestTools.TestTypes.Ordered.AutoSuiteTip, Microsoft.VisualStudio.QualityTools.Tips.OrderedTest.Tip, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'  
W, 2476, 1, 2018/09/07, 09:23:42.270, VWBUILD02\\MSTest.exe, TestType: #313, {ec4800e8-40e5-4ab3-8510-b8bf29b1904d}: Could not find string resource for name from 'Microsoft.VisualStudio.QualityTools.Tips.OrderedTest.Tip, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a:#313'  
V, 2476, 1, 2018/09/07, 09:23:42.270, VWBUILD02\\MSTest.exe, Test type {ec4800e8-40e5-4ab3-8510-b8bf29b1904d}: assosiated with editor {700218d8-f6f1-4ec3-be76-a35f72260503}  
W, 2476, 1, 2018/09/07, 09:23:42.271, VWBUILD02\\MSTest.exe, Total of 3 test types, loaded 3  
V, 2476, 1, 2018/09/07, 09:23:42.303, VWBUILD02\\MSTest.exe, Tmi.AddOrUpdateResult: AcceptChanges: started.  
V, 2476, 1, 2018/09/07, 09:23:42.304, VWBUILD02\\MSTest.exe, Tmi.AddOrUpdateResult: AcceptChanges: finished.  
V, 2476, 1, 2018/09/07, 09:23:42.310, VWBUILD02\\MSTest.exe, Tmi.CreateTestToCategoryRelationsAndExpressionColumns  
V, 2476, 1, 2018/09/07, 09:23:42.310, VWBUILD02\\MSTest.exe, Tmi.AddRelation: test2testXcat  
V, 2476, 1, 2018/09/07, 09:23:42.311, VWBUILD02\\MSTest.exe, Tmi.AddRelation: cat2testXcat  
I, 2476, 1, 2018/09/07, 09:23:42.342, VWBUILD02\\MSTest.exe, AggregatorManager: Creating aggregator: Microsoft.VisualStudio.TestTools.Execution.Aggregation.FileAggregator, Microsoft.VisualStudio.QualityTools.ExecutionCommon, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  
V, 2476, 1, 2018/09/07, 09:23:42.361, VWBUILD02\\MSTest.exe, Tmi.LoadTests from location: artifacts\\AX.Domain.Tests.dll  
W, 2476, 1, 2018/09/07, 09:23:42.375, VWBUILD02\\MSTest.exe, EqtException: Exception has been thrown by the target of an invocation.  
V, 2476, 1, 2018/09/07, 09:23:42.380, VWBUILD02\\MSTest.exe, Tmi.Dispose: starting  
V, 2476, 1, 2018/09/07, 09:23:42.380, VWBUILD02\\MSTest.exe, Tmi.Dispose: calling Dispose on proxies for runIds..  
V, 2476, 1, 2018/09/07, 09:23:42.380, VWBUILD02\\MSTest.exe, Tmi.Dispose: calling Dispose on proxies for remote Machines...  
V, 2476, 1, 2018/09/07, 09:23:42.380, VWBUILD02\\MSTest.exe, Tmi.Dispose: calling Dispose on TIPs...  
V, 2476, 1, 2018/09/07, 09:23:42.384, VWBUILD02\\MSTest.exe, BackgroundJobProcessor\<Microsoft.VisualStudio.TestTools.Execution.Aggregation.FileDataMessage\>(FileDataReceiver.FileDataMessageReceiver).DoAbort: Clearing 0 queued jobs and 0 jobs waiting to be queued  
V, 2476, 1, 2018/09/07, 09:23:42.386, VWBUILD02\\MSTest.exe, BackgroundJobProcessor\<Microsoft.VisualStudio.TestTools.Execution.Aggregation.FileDataMessage\>(FileDataReceiver.FileDataMessageReceiver).Dispose  
V, 2476, 1, 2018/09/07, 09:23:42.386, VWBUILD02\\MSTest.exe, BackgroundJobProcessor\<Microsoft.VisualStudio.TestTools.Execution.Aggregation.FileDataMessage\>(FileDataReceiver.FileDataMessageReceiver).DoAbort: Clearing 0 queued jobs and 0 jobs waiting to be queued  
V, 2476, 1, 2018/09/07, 09:23:42.388, VWBUILD02\\MSTest.exe, Tmi.Dispose: finished...  
V, 2476, 1, 2018/09/07, 09:23:42.389, VWBUILD02\\MSTest.exe, Runner.Main: Exiting with exit code 1  
V, 2476, 1, 2018/09/07, 09:23:42.389, VWBUILD02\\MSTest.exe, Runner.Main: finished.


Answers:
author: Roshan Fernandes
body: I started using VSTest.Console.exe instead of MSTest.exe.

I no longer use MSTest Runner task on bamboo server. I replaced it with two tasks: command task to execute VSTest.Console.exe executable and then MSTest Parser task to parse trx test results file.

comments: author: Gonchik Tsymzhitov
body: Ok:)


author: Gonchik Tsymzhitov
body: Hi!

Is this bamboo agent or server ?

Cheers,

Gonchik Tsymzhitov