Issue with .net core and portable format
See original GitHub issueAs you may know OpenCover uses Mono.Cecil to leverage the reading of PDB files and I was hoping that the latest release would resolve the issue identified with handling .net core (https://github.com/OpenCover/opencover/issues/610)
I upgraded to 0.9.6.3 through nuget (as it appeared work on portable format had been done between the the 0.9.6.1 and 0.9.6.3 releases) but the library is throwing an OutOfMemoryException(“Array dimensions exceeded supported range.”).
at Microsoft.Cci.Pdb.MsfDirectory..ctor(PdbReader reader, PdbFileHeader head, BitAccess bits)
at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Dictionary`2& tokenToSourceMapping, String& sourceServerData, Int32& age, Guid& guid)
at Mono.Cecil.Pdb.PdbReader.PopulateFunctions()
at Mono.Cecil.Pdb.PdbReader.ProcessDebugHeader(ImageDebugDirectory directory, Byte[] header)
at Mono.Cecil.ModuleDefinition.ProcessDebugHeader()
at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
at Mono.Cecil.ModuleReader.CreateModuleFrom(Image image, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
at OpenCover.Framework.Symbols.CecilSymbolManager.LoadSourceAssembly() in C:\Projects\opencover.git\working\main\OpenCover.Framework\Symbols\CecilSymbolManager.cs:line 126
I tried to investigate myself but the mainline has moved on and broken backward compatibility (SequencePoint related) and I can’t tell from your git history nor your releases which commit aligns with the nuget package 0.9.6.3.
Can you help by either
- resolution of the issue
- identify which commit was used to build the 0.9.6.3 release so that I can investigate the issue myself.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:14 (8 by maintainers)
Top Results From Across the Web
"PDB format is not supported" with .NET portable ...
The last couple of days I've been hunting down a problem - with the conclusion: My Visual Studio 2017 debugger can't work with...
Read more >NET application publishing overview
Learn about the ways to publish a .NET application. .NET can publish platform-specific or cross-platform apps. You can publish an app as ...
Read more >Instrumenting .Net Core 2.0 console app "File contains no ...
Instrumentation works if you don't use the Portable PDB format for the .Net Core assembly you are attempting to instrument.
Read more >Portable PDB format support
Repro: I have a .NET 4.5 application that references a class library project that targets multiple framework versions (.NET Core, .NET Standard, ...
Read more >Upgrading an existing .NET project files to the lean new ...
In Visual Studio 2017 and .NET Core 2 (and beyond) the csproj format is MUCH MUCH leaner. There's a lot of smart defaults,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@sawilde hey Shaun,
As you mentioned, in .NET Core, the pdb format changed. There’s nothing in 0.9.6 to handle the portable pdb files. What’s happening is that Cecil is trying to read a portable pdb file with the native pdb reader, and the native pdb reader crashes while misinterpreting the file. This particular exception has been fixed in master through #279.
To answer your question, the 0.9.6 nuget is maintained through the 0.9.6-nuget branch. 0.9.6.3 has been built off 0f397dbf7059eb1efdeeffe70bdaf13f99c2b447.
Now, to really fix the .NET Core scenario, you’re going to need support for portable pdbs which are in master and aimed at being released through 0.10 based on the master, which is now fairly stable.
There are breaking changes in 0.10 however. To help you update, please find bellow the current breaking change log:
Custom Attributes on interface implementation for winmd files
We used to have:
We now have:
That’s an easy change.
Lower Memory Usage
I’ve merged this branch, meaning that by default a
ModuleDefinitionkeeps an open handle on its file and needs to be disposed. The default behavior for aDefaultAssemblyResolver, which is caching, is to dispose all cached assemblies when the resolver is disposed.You may override that by setting the
InMemory = trueof theReaderParameters, but that will lead to more memory fragmentation.Because of this, if you were previously reading and writing an assembly on the same file, you need to change how you read and write your assembly to:
Portable Pdb Support
This is a large change that introduces support for the new portable pdb information. The nice thing is that when users transition to the new format, all features are supported, and you can debug a rewritten assembly without loss of debug information.
It also simplifies quite a bit the debug symbol reader / writer. For 0.11, I’ll look into improving the native pdb story.
Things that went away:
Instruction.SequencePointVariableReference.NameThe information moved to MethodDefinition.DebugInformation. You can use instead:
MethodDebugInformation.GetSequencePoint(Instruction)MethodDebugInformation.TryGetName(VariableDefinition, out string)@facedbook there’s nothing builtin. The Portable Pdb support uses the Cecil object model to represent debug symbol.
You need to work with the method.DebugInformation.