Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Visual Studio插入和获取Windows服务的代码覆盖率? 我试图用VisualStudio 2012高级工具获得一个用C++编写的Windows服务的代码覆盖率(我们称之为hello .exe)。到目前为止,我已经尝试使用本文答案中概述的方法:_C++_Visual Studio_Windows Services_Code Coverage - Fatal编程技术网

如何使用Visual Studio插入和获取Windows服务的代码覆盖率? 我试图用VisualStudio 2012高级工具获得一个用C++编写的Windows服务的代码覆盖率(我们称之为hello .exe)。到目前为止,我已经尝试使用本文答案中概述的方法:

如何使用Visual Studio插入和获取Windows服务的代码覆盖率? 我试图用VisualStudio 2012高级工具获得一个用C++编写的Windows服务的代码覆盖率(我们称之为hello .exe)。到目前为止,我已经尝试使用本文答案中概述的方法:,c++,visual-studio,windows-services,code-coverage,C++,Visual Studio,Windows Services,Code Coverage,为方便起见,给出的步骤是运行: vsinstr/coverage hello.exe 启动vsperfmon/coverage/output:mytestrun.coverage hello.exe vsperfcmd/关闭 当我在命令提示符下以可执行文件的形式启动hello.exe时,我能够插入、测试并获取该.coverage文件。没问题。但是,如果我在步骤3中尝试将其作为服务启动(手动通过services.msc或Python中的win32serviceutil.StartService),

为方便起见,给出的步骤是运行:

  • vsinstr/coverage hello.exe
  • 启动vsperfmon/coverage/output:mytestrun.coverage
  • hello.exe
  • vsperfcmd/关闭
  • 当我在命令提示符下以可执行文件的形式启动hello.exe时,我能够插入、测试并获取该.coverage文件。没问题。但是,如果我在步骤3中尝试将其作为服务启动(手动通过services.msc或Python中的win32serviceutil.StartService),则不会注册任何内容,覆盖率文件为空。这里有我遗漏的东西吗


    额外信息:为了解决这个问题,我遇到了另一个代码覆盖实用程序CodeCoverage.exe(Microsoft Visual Studio 11.0\Team Tools\Dynamic code coverage Tools)。这就是我应该用来完成这项任务的吗?此外,我在这里发现了一些似乎相关的东西,但(请原谅我的无知)不确定.NET服务是否与Windows服务相同。

    在这里回答我自己的问题,在大量尝试和翻阅文档后,我发现:

    基本上,windows服务不同于进程,因此我们必须启用跨会话标志,并在监视时指定用户

    start vsperfmon /coverage /output:mytestrun.coverage /cs /user:”Everyone”
    
    因此,只需像往常一样插入exe,使用上述命令启动监视,启动服务,进行测试,停止服务,然后关闭监视

    start vsperfmon /coverage /output:mytestrun.coverage /cs /user:”Everyone”
    
    希望它能帮助将来的人