Why is the coverage result file empty?

Why is the coverage result file empty?

Hi,

I have downloaded the source code v1.5 beta1 yaeterday, and regiested the CoverLib dll.

Then I tried to get the coverage of a application and spefified dll by NCover.Console.exe.

The command line is NCover.Console /c:WindowsApplication1.exe /a:ClassLibrary1.dll

When WindowsApplication1 running, click the button on its form, the ClassLibrary will be called. But the generated xml report is empty, why?

My machine is WinXP, and Japanese core language.

Can you help me? I want to attached my application1, but no permission.


Re: could not connect profiler to windows service

Ron,

What version of NCover/OS? What does it say in the event log? Are you running under a local admin account (I don't know if you have to, just curious)? Is CoverLib.dll registered? Any log file produced?

I've never had to profile a service myself (prefering to write the service as a lightweight wrapper and test the code the service calls instead). So I didn't personally test NCover 1.5.7 against services - not sure what testing Peter did with these but it's always possible it got broken along the way although don't remember seeing any changes to this part of the code.


Re: could not connect profiler to windows service

Hi Kiwidude, thanks for your reply :-),

Well, about the NCover/OS versions i'm working with 1.5.5 build of NCover over a W2K3 stnd machine, and about the event log under system events I found this two timeout errors:

    - Timeout (30000 milliseconds) waiting for the MyService service to connect.

    - The MyService service failed to start due to the following error:
       The service did not respond to the start or control request in a timely fashion.

I'm sure that the CoverLib.dll is correctly registered, because I was able to perform coverage of a win32 app just before trying to start the profiler for the service

No log file is being produced.

I was thinking to implement something like the wrapper, but i'm not sure if it can reproduce the real testing environment, this is really an interesting point but it would be great to test the service as it is supposed to work :-).


Re: could not connect profiler to windows service

Hi Ron,

Without actually getting as far as debugging why I was able to replicate your issues when I knocked up a quick test service. I have dropped Peter an email with the details so hopefully he can enlighten us. There is another thread here with similar issues.
http://ncover.org/SITE/forums/thread/1110.aspx

I believe one of the issues that can arise is that for windows services you need to register coverlib.dll using regsvr32 rather than relying on //reg (current user registry trick). Whether you get the error message about failing to start the service, or getting a "Waiting for profiled application to connect..." seems to be dependent on the account that your run the service under (local system account or a named account).


Re: could not connect profiler to windows service

Version 1.5.8 fixes this problem.


Re: could not connect profiler to windows service

Maybe not, at least not for all cases.

I just tried out 1.5.8. And ran into this:

C:\CodeCoverage>ncover.console //svc LKGService //l C:\CodeCoverage\LKGSvcCovera
ge.log //x C:\CodeCoverage\LKGSvcCoverage.xml
NCover.Console v1.5.8 - Code Coverage Analysis for .NET - http://ncover.org
Copyright (c) 2004-2006 Peter Waldschmidt

Command:
Command Args:
Working Directory:
Assemblies:
Coverage Xml: C:\CodeCoverage\LKGSvcCoverage.xml
Coverage Log: C:\CodeCoverage\LKGSvcCoverage.log

Stopping Service [LKGService]...
Starting Service [LKGService]...
Press Control-C to stop the service and collect coverage data.

Waiting for profiled application to connect...Connected
No value exists with that name.

C:\CodeCoverage>
Just to be sure NCover was working, I tested against a GUI executable and that worked fine.

Even though it says connected, monitoring services manager, I see the service is starting and then its status changes to blank (not started). And NCover of course has aborted operation.


Re: could not connect profiler to windows service

Any clue what kind of error is occurring?  i.e. Windows Event Log record, or Coverage log file?


Re: could not connect profiler to windows service

I also have this error

>"C:\Program Files\NCover\NCover.Console.exe //svc "ServiceName"
NCover.Console v1.5.8 - Code Coverage Analysis for .NET - http://ncover.org
Copyright (c) 2004-2006 Peter Waldschmidt

Command:
Command Args:
Working Directory:
Assemblies:
Coverage Xml: Coverage.Xml
Coverage Log: Coverage.Log

Stopping Service [ServiceName]...
Starting Service [ServiceName]...
Press Control-C to stop the service and collect coverage data.

Waiting for profiled application to connect...Connected
No value exists with that name.

This is occuring for two different Debug-build .NET Windows services, one of which runs as Network Service and one that runs as my interactive login account.

Also note that the time between "Connected" and "No value..." is less than 1 second.  there certainly is not a 30second wait for the service to start.

As far as I can tell, the main issue is that the service is not given time to start.

 

Any help appreciated,

Mike.


Re: could not connect profiler to windows service

This is what I see in the System Event Log:

-------------------------
@ 4/27/07 1:47:44 pm
Event ID: 7009
Timeout (30000 milliseconds) waiting for the [service name] service to connect.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

@ 4/27/07 1:47:44 pm
Event ID: 7000
The [service name] service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
-------------------------

There are also 2 entries in the Application Event Log. I did manually start the service after it failed to start. So correlating the 2 event logs, this is what I have:

@ 1:47:14 pm, the service stopped successfully.
@ 1:47:44 pm, attempt to start service timed out "waiting to connect" and hence failed to start.
Sometime between this time and 1:48:21 pm, I manually started the service after seeing that it didn't start in the Services Manager window.

There was no new coverage.log file (but there is one from a past test of NCover v1.5.7 in the same location). I assume NCover would have no problem overwriting it if it were to log information.


Re: could not connect profiler to windows service

Exact same problem here, i'm running Vista with the latest version of NCover...

Although i found a way around to profile my services...  I have a debug version snippet code for services...

#if (!DEBUG)
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] { new ContactImportService() };
            ServiceBase.Run(ServicesToRun);
#else
            // Debug code: this allows the process to run as a non-service.
            // It will kick off the service start point, but never kill it.
            // Shut down the debugger to exit
            ContactImportService service = new ContactImportService();
            service.StartService();
            // Put a breakpoint on the following line to always catch
            // your service when it has finished its work
            System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
#endif

Where StartService(); is the method that creates the worker threads, etc...

Just use the windows console mode of nCover and it will all work fine...