AxoCover icon indicating copy to clipboard operation
AxoCover copied to clipboard

Code coverage fails after upgrading to VS 15.7.5

Open pablocar80 opened this issue 6 years ago • 12 comments

Hi, I updated VS to version 15.7.5 released a few days ago and AxoCover stopped being able to show the coverage. To solve this, I created a new testing project with only the following test:

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
        }
    }
}

I already uninstalled completely VS and installed it again. AxoCover worked for a while, and then stopped working again. Here is the detailed output:

Executing tests... | Runner version is 1.1.389.0. | We are on x86 platform. SerializableException: Could not load file or assembly 'AxoCover.Runner.XmlSerializers, Version=1.1.389.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) SerializableException: Could not load file or assembly 'AxoCover.Runner.XmlSerializers' or one of its dependencies. The system cannot find the file specified. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) | File redirection is enabled for the following files: | C:\Users\Pablo\AppData\Local\Microsoft\VisualStudio\15.0_6cc15c00\Extensions\ntrocxop.dn2\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll | C:\Users\Pablo\AppData\Local\Microsoft\VisualStudio\15.0_6cc15c00\Extensions\ntrocxop.dn2\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll | C:\Users\Pablo\AppData\Local\Microsoft\VisualStudio\15.0_6cc15c00\Extensions\ntrocxop.dn2\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll | C:\Users\Pablo\AppData\Local\Microsoft\VisualStudio\15.0_6cc15c00\Extensions\ntrocxop.dn2\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.TestFramework.dll | C:\Users\Pablo\AppData\Local\Microsoft\VisualStudio\15.0_6cc15c00\Extensions\ntrocxop.dn2\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll | Setting up file redirection hooks... | File redirection hooks are enabled.

Loading assembly from C:\Users\Pablo\AppData\Local\Microsoft\VisualStudio\15.0_6cc15c00\Extensions\ntrocxop.dn2\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll... || Loaded executor: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor << Assembly loaded. Running executor: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor... || Processing tests in: C:\Users\Pablo\SkyDrive\Documents\Visual Studio 2017\Projects\UnitTestProject1\UnitTestProject1\bin\Debug\UnitTestProject1.dll... SerializableException: Element not found. (Exception from HRESULT: 0x80070490) SerializableException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetTargetFrameworkVersionStringFromPath(String path) at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetTargetFrameworkVersionStringFromPath(String path) at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.AppDomainUtilities.GetTargetFrameworkVersionString(String testSourcePath) Passed UnitTestProject1.UnitTest1.TestMethod1 << Executor finished. | File redirection rules are cleared. < Test execution finished. Shutting down... Exiting... Generating coverage report... SerializableException: The I/O operation has been aborted because of either a thread exit or an application request at System.ServiceModel.Channels.SocketConnection.HandleReceiveAsyncCompleted() Committing... No results, this could be for a number of reasons. The most common reasons are: 1) missing PDBs for the assemblies that match the filter please review the output file and refer to the Usage guide (Usage.rtf) about filters. 2) the profiler may not be registered correctly, please refer to the Usage guide and the -register switch. Test execution finished.

pablocar80 avatar Jul 16 '18 13:07 pablocar80

We're getting the same error since we've updated our machines to the latest windows 10 updates. I'm guessing the issue is with OpenCover and not AxoCover but nothing has been reported on their Issues page yet.

Eritey avatar Jul 16 '18 14:07 Eritey

I just updated to latest VS, tried AxoCover and it still worked. I restarted the machine, and reinstalled AxoCover but it still works as before. I am on latest windows 10 too.

I see some errors from 4 users in telemetry, saying "This program is blocked by group policy. For more information, contact your system administrator", however it seems to run the tests for you - at least without coverage, so that should not be the issue.

I will try with another machine tomorrow.

axodox avatar Jul 19 '18 20:07 axodox

Our tests still run successfully, its just the coverage that doesn't. Which is why I'm thinking its a problem with OpenCover and not AxoCover.

Eritey avatar Jul 20 '18 09:07 Eritey

I was able to reproduce it on my other machine. You are right it is indeed OpenCover. The problem is that it's DLL registration does not work anymore - probably because of some change in Windows. Fortunately I have found a workaround for now:

  • Go to the directory where AxoCover is installed. You can locate this by running a long test (e.g. thread sleep, and open the file location of the AxoCover.Host-*.exe from the task manager. For example for me it is: C:\Users\axodo\AppData\Local\Microsoft\VisualStudio\15.0_6d93d79f\Extensions\pfu3q5ow.kny\
  • Then navigate to OpenCover\x86 or x64 depending on what platform your tests are running
  • Open CMD with admin right
  • Enter: regsvr32 /i OpenCover.Profiler.dll
  • You will get a dialog that DLL is registered.

Now your coverage will run again. I will check at the weekend to make this automatically in AxoCover, while OpenCover gets fixed. Or check if I can fix OpenCover myself.

axodox avatar Jul 20 '18 10:07 axodox

This worked for me

markmercer10 avatar Aug 01 '18 13:08 markmercer10

Also worked for us. Do not forget to try both x64 or x86 if the former doesn't work.

jbarradas avatar Aug 07 '18 15:08 jbarradas

Registering by hand worked indeed. The issue itself appears to have something to do with per-user registration (on Windows 7), which I didn't know existed before, and not with Visual Studio itself.

The OpenCover command line tool also supports registering and unregistering using the administrator account using the -register:Path32 and -register:Path64 instead of -register:user.

Chippychap avatar Aug 14 '18 14:08 Chippychap

Thanks It worked for me as well.

userIsNikunj avatar Sep 20 '19 13:09 userIsNikunj

@axodox It is quite possible that in some cases #207 is the reason which should be fixed withing #208 PR + human intervention on his settings tab in AxoCover

jgasiorowski avatar Sep 27 '19 14:09 jgasiorowski

Thanks! This saved me. I was struggling since morning with this.

idrisfl avatar Feb 10 '20 15:02 idrisfl

This worked for me too! Thank you!

ajt13a avatar Feb 26 '20 13:02 ajt13a

this works for me! thanks!

wesley-wws avatar Oct 12 '21 08:10 wesley-wws