文件的符号数据无效吗?

时间:2019-05-07 17:19:00

标签: .net visual-studio code-coverage

我有一系列有效的.coverage文件,我正在尝试使用Microsoft.VisualStudio.Coverage.Analysis.CoverageInfo.BuildDataSet()方法合并为一个数据集。但是,我遇到异常“ Microsoft.VisualStudio.CodeCoverage.Analysis.SymbolsNotFoundException:找不到图像文件'myassembly.dll'的符号。”

我需要帮助解决此异常。

我已验证/尝试过的事情:

  • 已验证单个.coverage文件是否有效,并且即使对于我收到上述异常的程序集也包含coverage数据。
  • 验证已检测的.dll,.pdbs,.coverage文件和以下代码均位于同一目录中。
  • 当我调用包含MissingFileCallback的CoverageInfo.CreateFromFile重载时,我看到缺少的文件的文件名是“ myassembly.instr.pdb”而不是“ myassembly.pdb”。不知道这是否正确。对我来说似乎很可疑,但是我不知道在文件名后加上“ .instr”是什么,或者如何解决。
public static void CombineFiles(IEnumerable<string> files, string DestFilePath)
        {
            CoverageDS data = JoinCoverageFiles(files).BuildDataSet();
            data.ExportXml(DestFilePath);
        }

// From https://blogs.msdn.microsoft.com/phuene/2009/12/04/programmatic-code-coverage-data-merging-in-visual-studio-2010/
private static CoverageInfo JoinCoverageFiles(IEnumerable<string> files)
        {
            if (files == null)
                throw new ArgumentNullException("files");

            // This will represent the joined coverage files
            CoverageInfo result = null;

                foreach (string file in files)
                {
                    // Create from the current file

                    CoverageInfo current = CoverageInfo.CreateFromFile(file, new MissingFileCallback(OnMissingFile));
                    if (result == null)
                    {
                        // First time through, assign to result
                        result = current;
                        continue;
                    }

                    // Not the first time through, join the result with the current
                    CoverageInfo joined = null;

                        joined = CoverageInfo.Join(result, current);


                    result = joined;
                }
            }
            return result;
        }

0 个答案:

没有答案