VS 2012抛出异常时运行代码覆盖率分析 [英] Running code coverage analysis on VS 2012 throwing exception

查看:150
本文介绍了VS 2012抛出异常时运行代码覆盖率分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在VS 2012中运行代码覆盖时,我突然开始出现以下异常:

I suddenly started getting following exception while I am trying to run the code coverage in VS 2012:

引发了异常:代码覆盖率分析引擎引发了异常:
覆盖文件
........ coverage无效或损坏

Exception was thrown: Code Coverage Analysis engine threw exception(s): Coverage file "........coverage" is invalid or corrupt

任何解决方案/解决方法都将有所帮助。 / p>

Any solution/ workaround would be helpful.

推荐答案

我在VS2010中看到了此错误,至少可以说这令人沮丧。该错误很可能与一个或多个未正确插入的程序集有关。我记得从内存中可以通过在测试设置中取消选择适当的插入程序集来解决。

I have seen this error in VS2010 and it's frustrating to say the least. The error is likely related to one or more assemblies that don't get "instrumented" correctly, From memory I recall it can be solved by unselecting "instrument assemblies in place" in the test settings.

关于原地安装,当打开代码覆盖率时,Visual Studio会花一些时间在TestRun上重写程序集的IL,以便它可以记录执行IL的哪些部分。 就地仪器会创建扩展名为 .instr的程序集的备份,在打开探查器的情况下运行测试,然后在测试完成后将检测的程序集替换为原始程序集。当我看到此错误时,似乎无法还原原始文件(可能已锁定),并且在构建输出文件夹中有一些剩余的 .instr程序集。我的理论是IDE试图将coverage数据与原始装配相关联,但是由于这种不匹配而失败。

Regarding "instrumenting in place", when code coverage is turned on Visual Studio takes a few moments before the TestRun to rewrite the IL for your assemblies so that it can record which parts of the IL are executed. "Instrumenting in place" creates a back up of the assembly with a ".instr" extension, runs the tests with the profiler turned on, then replaces the instrumented assembly with the original assembly after the Tests complete. When i was seeing this error it seemed as though the original file could not be restored (possibly locked) and i had a few remnant ".instr" assemblies in my build output folder. My theory is that the IDE tries to correlate the coverage data to the original assembly but fails because of this mismatch.

AFAIK,关闭原位没有明显差异本地查看覆盖率时的检测。

AFAIK, there are no visible differences to turning off in place instrumentation when viewing coverage locally.

这篇关于VS 2012抛出异常时运行代码覆盖率分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆