I'm using XBuild to compile Visual Studio solutions for Mono. This generates the assembly + mdb file. Is there a possibility to debug this assembly with Visual Studio on Windows? When using "Attach to process" i can't debug because an error is shown that the symbols aren't loaded.
I tried generating the pdb file for this assembly via Mono.Cecil (AssemblyDefinition, MdbReaderProvider, PdbWriterProvider) and loading it manually via Debug / Windows / Modules and "Load Symbol From / Symbol Path", which actually loads the symbols (shown in the Modules windows) but that doesn't enable debugging either.
When comparing assembly definitions between VS2012 builds and XBuild builds, i noticed that XBuild is not generating the DebuggableAttribute. If this attribute is missing, debugging with Visual Studio 2012 isn't possible, even if you load the symbols manually. Following steps are needed to debug assemblies compiled with Mono / XBuild with VS2012:
Code for generating pdb and injecting DebuggableAttribute:
This is possible with a little one-time effort.
You need to convert the mono
mdb
files topdb
files. After that VS should be able to step through the code with you (if you have the sources too) - see below.http://johnhmarks.wordpress.com/2011/01/19/getting-mono-cecil-to-rewrite-pdb-files-to-enable-debugging/
Mono.Cecil does change quite frequently so you may find the API has changed a little for this.