Exception when running two ncover instances at once

Exception when running two ncover instances at once

I was running ncover with NAnt and CruiseControl.NET to get code coverage.

Everything worked fine when I was running NCover on once project.

But when I added ncover on a different project (which sometimes builds at the same time as the first project) I started having failed builds (from both the first and second project).

The problem is that the projects are similar and share some dependencies.

This is the result from NAnt

[exec] NCover.Console v1.3.3 - Code Coverage Analysis for .NET - http://ncover.org
[exec] ******************* Program Output *******************
[exec] NUnit version 2.2.2
[exec] Copyright (C) 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole.
[exec] Copyright (C) 2000-2003 Philip Craig.
[exec] All Rights Reserved.
[exec] OS Version: Microsoft Windows NT 5.2.3790.0 .NET Version: 1.1.4322.2300
[exec] .........................................................................................................................................................................................................................................................................................................................................................N......................N.N....................................................................................................................
[exec] Tests run: 481, Failures: 0, Not run: 3, Time: 25.297 seconds
[exec] Tests not run:
[exec] 1) UnitTests.TDTest.AccessTDPageWithParameters : This one fails for no reason sometimes
[exec] 2) UnitTests.HejTest.CreateHejPage :
[exec] 3) UnitTests.HejTest.CreateNHPage :
[exec] Unhandled Exception:
[exec] System.UnauthorizedAccessException: Access to the path "Tradera.NET.DLL" is denied.
[exec] at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive)
[exec] at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)
[exec] at System.IO.DirectoryInfo.Delete(Boolean recursive)
[exec] at NUnit.Util.TestDomain.DeleteCacheDir(DirectoryInfo cacheDir)
[exec] at NUnit.Util.TestDomain.DeleteCacheDir(DirectoryInfo cacheDir)
[exec] at NUnit.Util.TestDomain.DeleteCacheDir(DirectoryInfo cacheDir)
[exec] at NUnit.Util.TestDomain.DeleteCacheDir(DirectoryInfo cacheDir)
[exec] at NUnit.Util.TestDomain.DeleteCacheDir(DirectoryInfo cacheDir)
[exec] at NUnit.Util.TestDomain.DeleteCacheDir(DirectoryInfo cacheDir)
[exec] at NUnit.Util.TestDomain.Unload()
[exec] at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
[exec] at NUnit.ConsoleRunner.ConsoleUi.Main(String[] args)
[exec] ***************** End Program Output *****************
[exec] Copied 'D:\build\Tradera.NET\tools\ncover\Coverage.xsl' to 'D:\build\Tradera.NET\build_staging\test-reports\Coverage.xsl'

Build Error: NAnt.Core.BuildException
External Program Failed: ncover.console.exe (return code was 2)
--

The dependency Tradera.NET.DLL is referenced by both the first and second project. I will not always get an exception about this dependency but it is always a dependency that is referenced by both projects.

What can I do to fix the problem?

Right now I have do "force build" and the project always builds fine.

 


Re: "Profiled process terminated. Profiler connection not establ

I'm having a similar issue, I've relocated the NCover folder and the <ncover> task is failing to register the dll in the new location. Manually registering the dll solves the issue for now.


Re: &quot;Profiled process terminated. Profiler connection not establ

Hi guys,

I cant' replicate the issue - its all working fine for me. Do a search in your registry to make sure you havent got any stray entries for "coverlib.dll" in there.

Using 1.3.6.11, my NCover task in my NAnt script looks like this:

<project name="NCoverCoverage" default="coverage" xmlns="http://nant.sf.net/schemas/nant.xsd">;
  <description>Profile application using NCover.</description>
  <target name="coverage" description="Generate code coverage using NCover">
    <ncover program="E:\Apps\NCover\1.5.7\NCover.Console.exe"
            commandLineExe="NCoverDemo.exe"
            excludeAttributes="CoverageExcludeAttribute"
            coverageFile="Coverage\nantCoverage157.xml"
            logFile="Coverage\nantCoverage157.log"
            logLevel="Normal"
    />
  </target>
</project>

Take a look in the registry at the following key:
HKEY_CURRENT_USER\Software\KiwiDevelopment\NCoverExplorer

After running the task at least once, there should be a DWORD pair in there called "NCoverRefCount" with a value of 0. If this is not 0, set it to 0 and try again (although I would love to know how it got left in a non-zero state). The ncover tasks will now only register/unregister the coverlib.dll if the refcount is 0.


Re: &quot;Profiled process terminated. Profiler connection not establ

Tried to register the DLL manually... got this:
LoadLibrary("CoverLib.dll") failed - This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.


Re: &quot;Profiled process terminated. Profiler connection not establ

Have you got the necessary Microsoft .dlls in the same directory as NCover? These are:

Microsoft.VC80.CRT.Manifest
MSVCP80.dll
MSVCR80.dll


Re: &quot;Profiled process terminated. Profiler connection not establ

Hey Kiwidude, Thanks for the help, resetting the subkey value to 0 solved the issue. Most likely the way that it was left set was that i killed the process by hitting Ctrl-C while it was running the coverage tests.

I've found another subkey that contains the old location of CoverLib.dll in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\E72525ECF0CD0F5458A9B200C1A1595B
trying to uninstall coverlib.dll from that location fails, any idea why the key is there?


Re: &quot;Profiled process terminated. Profiler connection not establ

Thanks Greg for the info on why that registry entry got out of sync. Think I'm going to have to enhance that ncover task code a bit more to start looking for the presence of the key etc so the task can "self recover" better. It was a fairly crude first stab and I'm sure you won't be the last person to get caught out by it!

As for that subkey - my guess would be when you ran the NCover msi installer at some point? Was the location C:\Program Files\NCover\ by any chance? I think you would be safe in deleting it if you no longer have NCover installed there.

A note for people using TestDriven.Net (this one caught me out once). If you install NCover 1.5.7 using the NCover msi, as well as installing TestDriven.Net, then TD.Net will assume that the NCover installed at C:\Program Files\NCover\ is the one to be used. Where this can cause a problem is if you unregister coverlib.dll manually from there but not delete the files. TD.Net assumes that any NCover located there is already registered and won't do so itself - result in the same "Profile process terminated..." message.

The solution? Either register coverlib.dll in C:\Program Files\NCover\, or uninstall NCover and let TD.Net use the version it ships with. If you have the latest TD.Net installed (build 2.5.xxx) then it should be the same NCover 1.5.7 anyways. An aside probably worth adding to Peter's FAQ (or Jamie's for that matter).


Re: &quot;Profiled process terminated. Profiler connection not establ

Mmmm...!

For an obscure reason, the manifest was not there!

Thanks for the help!

nick