NullReferenceException while running unit tests in VS 2017
Hi JetBrains team and community,
a few days ago, out of the blue, I´ve got a NullReferenceException when trying to execute unit tests in my C# project in VS 2017 (tests were working fine until that moment). I´m using ReSharper Ultimate 2018.1.4 (updated after the problem occurred first). VS is also updated to the newest version. The problem occurs with every existing unit test in the solution, even if I go back to older versions of the code (using Git). Some colleagues are affected as well, others not. We compared VS and ReSharper settings and versions, they are all the same. Of course we tried to clean ReSharper cache as well. The problem remains even with a brand new check out (Git clone) into an empty directory. Strange thing is, that on some machine the tests are still working while on others they don´t. Please note that only one solution is affected, all others I´m working with are ok, means unit tests can be executed!
So far we have absolutely no idea how to solve this. Here is the exception ReSharper shows:
2018.08.07 17:35:07.238 ERROR System.NullReferenceException: Object reference not set to an instance of an object.
at JetBrains.ReSharper.UnitTestProvider.nUnit.v30.NUnitServiceProvider.GetRunStrategy(IUnitTestElement element)
at JetBrains.ReSharper.UnitTestProvider.nUnit.v30.Elements.NUnitElementBase.GetRunStrategy(IHostProvider hostProvider)
at JetBrains.ReSharper.UnitTestFramework.Launch.Stages.BuildStage.CollectProjectsToBuild()
at JetBrains.ReSharper.UnitTestFramework.Launch.Stages.BuildStage.Run(CancellationToken onCancel, CancellationToken onAbort)
at JetBrains.ReSharper.UnitTestFramework.Launch.UnitTestLaunch.<RunStage>d__68.MoveNext()
If you need more details for helping us please let me know what exactly do you need.
However, the product itself is a large commercial application, so I will not be able to provide any source code or project files.
Looking forward to your answers...
Daniel
Please sign in to leave a comment.
Hello Daniel!
Thank you for contacting us.
Is there any chance you could provide the solution that demonstrates the problem. You can do it privately via 'Submit a request' form. We can also sign NDA if needed.
Thank you.
Hi Angelina,
thanks for your answer. As I mentioned above, I´m not able to provide any source code since this is a large commercial application which is confidential.
However, we have been able to solve the problem yesterday. Here is what we did:
- update ReSharper to latest version 2018.1.4
- install .NET Core 2.1
The latter was the most important step. Since our architects changed project files somehow, .NET Core is required now (some developers did not know this ;) )
So.... problem is fixed now.
Cheers,
Daniel
Hello Daniel!
Thank you for letting us know. Glad to know the problem is fixed.
Please feel free to contact us in case of any questions or problems.
Thank you.