I tried to use a PDB file to map the Instructions to the Sequencepoints in Mono.Cecil and find out the line number of a method. But none of the answers in any forum seems to work, because no matter what I try the SymbolsNotMatchingException is thrown with the error message
Symbols were found but are not matching the assembly".
By the way, my target "application" is a Unity Game.
Here is some code I use (side note: ProjectPath is the path to my target *.dll
):
var resolver = new DefaultAssemblyResolver();
resolver.AddSearchDirectory(GetDLLsFolderToResolve(ProjectPath));
using var assembly = AssemblyDefinition.ReadAssembly(ProjectPath,
new ReaderParameters { ReadWrite = true, AssemblyResolver = resolver,
SymbolReaderProvider = new PdbReaderProvider(), ReadSymbols = true });
I have already the Mono.Cecil.dll
and Mono.Cecil.Pdb.dll
in the same folder due to import Mono.Cecil via NuGet. Also, the target DLL and the PDB also are in the same folder.
Does anybody have a working example? Or any idea how this error could be solved? Would be happy for any help.