Hi, is there a way to find out using Mono.Cecil (from a assembly that was
compiled with debug symbols) the original path of the pdb file?

The reason I need this is that I need to know where the *.pdb file for a
particular assembly so that I can load it and get the source code references
for IL code (used when I convert an Assembly into
O2Platform<http://www.owasp.org/index.php/OWASP_O2_Platform>'s
CIR)

In the code example below my only solution is to see if the pdb is on the
same directly as the assembly:

public void loadAndMapSymbols(AssemblyDefinition assemblyDefinition,
stringassemblyPath
, bool decompileCodeIfNoPdb, string pathToSaveDecompiledSourceCode)
        {
            try
            {
                if (assemblyPath != null)
                {
                    var pdbFile = assemblyPath.Replace(Path.GetExtension(
assemblyPath), ".pdb");
                    if (File.Exists(pdbFile))
                    {
                        string unit = assemblyPath;
                        ModuleDefinition modDef = assemblyDefinition.
MainModule;
                        var pdbFactory = new PdbFactory();
                        ISymbolReader reader = pdbFactory.CreateReader(
modDef, unit);
                        modDef.LoadSymbols(reader);
                    }
                    else
                    {
                        if (decompileCodeIfNoPdb)
                            new CecilDecompiler().decompile(
assemblyDefinition, pathToSaveDecompiledSourceCode);
                    }
                }
            }
            catch (Exception ex)
            {
                PublicDI.log.error("in loadAndMapSymbols: {0]", ex.Message);
            }
        }
(code sample from
http://code.google.com/p/o2platform/source/browse/trunk/O2%20-%20All%20Active%20Projects/O2Core/O2_Core_CIR/CirCreator/DotNet/CirFactory.cs
)

Thanks

Dinis Cruz

Blog: http://diniscruz.blogspot.com
Twitter: http://twitter.com/DinisCruz
Web: http://www.owasp.org/index.php/O2
-- 
--
mono-cecil

Reply via email to