An exception occurred while invoking executor 'executor://mstestadapter/v1': Object reference not set to an instance of an object
Asked Answered
B

9

24

We are using Visual Studio 2012 and Team Foundation Server 2010 in our project. Since, we are using Microsoft Fakes, we could have not used the started Test functionality of our Team Build 2010, I have created a build activity which invokes VSTest.Console.exe passing the test assemblies. This approach has been working well for us. However, after a recent check-in we are getting the following error when executing Vstest.console.exe

Error: An exception occurred while invoking executor 'executor://mstestadapter/v1': Object reference not set to an instance of an object.

I copied the binary files to my local machine and was able to get the error again. Interestingly, we run a dev build before check-in which runs the same vstest.console.exe with the same parameters and that works correctly. I have got two folders on my machine, for one the call works fine and for other it doesn't. The compiled assemblies look same size and there aren't much differences to suggest.

I tried using Process Monitor but couldn't find anything obvious other than that the process returns with an exit code 1. Does anybody know much about this error? Is there any way I can find out more information from my test run?

Regards,

Hamid

Bacillus answered 24/1, 2013 at 15:34 Comment(0)
B
6

We got to the bottom of the problem. We are using Entity Framework 5.0 and we also have a situation where some of our test assemblies are targeting .Net 4.0 and some are targeting .Net 4.5.

When we are trying to run the tests such that assemblies targeting different versions of .Net framework and using Entity Framework 5.0 are run in the same Test (vstest.console.exe) process, we get this error.

I think this has to do with the way Entity Framework 5.0 ships with two versions (net40 and net45). Once one version of the library is loaded in the process, the other version cannot be loaded and this caused the error.

Bacillus answered 30/1, 2013 at 15:56 Comment(0)
S
9

I had the same error message just now with Visual Studio 2017 using the new MSTest.Framework and MSTest.TestAdapter (to be able to use Live Unit Testing). It turned out I was using multiple versions of those packages in my solution. Consolidating them to the latest version solved the problem.

Sulcus answered 15/6, 2017 at 12:22 Comment(2)
This was my problem. Specifically, I needed to clean and then build. I had redundant assemblies.Tinkling
this was my problem for Dev Azure with VS 2017Hodometer
B
6

We got to the bottom of the problem. We are using Entity Framework 5.0 and we also have a situation where some of our test assemblies are targeting .Net 4.0 and some are targeting .Net 4.5.

When we are trying to run the tests such that assemblies targeting different versions of .Net framework and using Entity Framework 5.0 are run in the same Test (vstest.console.exe) process, we get this error.

I think this has to do with the way Entity Framework 5.0 ships with two versions (net40 and net45). Once one version of the library is loaded in the process, the other version cannot be loaded and this caused the error.

Bacillus answered 30/1, 2013 at 15:56 Comment(0)
C
5

An exception occurred while invoking executor 'executor://mstestadapter/v2'

I had multiple TestAdapter's and TestFramework's in my BuildAgents Folder, deleting the v1.1.11 versions fixed the issue:

enter image description here

Coff answered 28/6, 2017 at 4:48 Comment(1)
I had this same problem in Azure DevOps trying to run Integration Tests in Release Pipeline. This post helped me realize my root cause of the problem was I had two different test projects with mismatched NuGet packages, and the Release was trying to run tests from both Projects inside a single Test Artifact during the Test step of the Release.Diabetes
I
4

This is what worked for me: In Visual Studio, Test -> Test Settings -> Default Processor Architecture -> X64.

Though it might not solve everyone's issue, hope it helps some of you out there.

Incunabulum answered 29/11, 2017 at 12:30 Comment(0)
E
3

This happened to me recently in VS 2019. Using NuGet to update to the latest versions of MSTest.TestAdapter and MSTest.TestFramework solved the problem for me.

Exuberant answered 5/4, 2021 at 15:59 Comment(0)
F
2

I have the same error specified in the subject when in the AssemblyInfo of the project is specified the AssemblyAttribute:

[assembly: AssemblyCulture("en")]

If this attribute is present, the run of the unit tests fails. If I remove this line of code or I remove the en language, the run of the unit tests success.

Frumentaceous answered 18/4, 2013 at 8:24 Comment(2)
This fixed it for me. Anyone have any idea why this would prevent tests from running? I mean, who would think an AssemblyCulture attribute would affect your unit tests....Breeches
The MS Test framework parses the Types in your assemblies to see which ones are marked with the TestClass and TestMethod attributes. Presumably it does this through reflection GetCustomAttribute. Possibly as it enumerates the Assembly and gets its attributes it doens't handle the AssemblyCulture properly ? Its a wild guess - what its doing parsing the Assembly attributes rather than just the Type attributes is anyones guess.Grope
G
0

I tried everything on the web to solve this exception. Finally I solved this issue by installing the Update v4 of Visual Studio 2013 (which is that I'm using currently). Hope it helps!

Gonadotropin answered 28/11, 2014 at 18:40 Comment(0)
A
0

Deleting app.config and packages.config, if exists, and reinstalling Entity framework via nuGet packages works for me.

Alphonso answered 29/3, 2015 at 5:31 Comment(0)
N
0

Saw this error when I tried updating from 1.x to 2.x of the MSTest.TestAdapter and MSTest.TestFramework packages.

Just had to clean solution and close/restart VS, and that seemed to fix it. Imagine these get loaded by the VS Test explorer and VS has to re-initialize or something when trying to upgrade.

Ne answered 1/2, 2024 at 22:55 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.