¿Cómo puedo depurar complementos de MonoDevelop con MonoDevelop?

The topic says it all. I cannot find any information on the monodevelop site or through google.

Incluso agregando System.Diagnostics.Debugger.Break() y corriendo con mono --debug MonoDevelop.exe doesn't seem to do anything..

preguntado el 09 de marzo de 12 a las 16:03

2 Respuestas

mono --debug doesn't have anything to do with the debugger, it simply causes Mono to track debug information so it can give you file/line/col information in backtraces.

El comportamiento de System.Diagnostics.Debugger.Break() depends on your Mono version. AFAIK in its basic form it sets a hard breakpoint, so if your app's not running in a native hard debugger it will simply crash. If your app is running inside the Mono Soft Debugger with Mono 2.11 or later (which has not yet been released), it will set a soft breakpoint for the soft debugger and work as expected.

The basic way to enable debugging of addins is to set a custom execution command in your addin project. Open 'Project Options', got to the 'Run>Custom Commands' section, add a custom command for 'Execute'. Set the executable to MonoDevelop.exe and the working directory to be its containing directory. This means that when you run/debug your project, MD will actually execute that executable instead of executing your project directly. If MonoDevelop.exe loads your addin, then you'll be able to set breakpoints, step, etc.

The difficult part here is making MD load your addin. One way to do this would be to have your project output the addin dll into one of the directories that MD searches for addins, but that's a very hacky thing to do at development time. A better solution is to use the undocumented environment variable MONODEVELOP_DEV_ADDINS to specify an additional directory from which for MD to load addins. There isn't a UI in MD for setting env vars for custom commands, but it is supported internally - you'll have to manually edit the csproj file.

Find the part that looks like:

    <Command type="Execute"
      workingdir="..\..\..\monodevelop\main\build\bin" />

Y cámbielo a:

    <Command type="Execute"
        <Variable name="MONODEVELOP_DEV_ADDINS" value="${TargetDir}" />

Si te estás preguntando por qué <CustomCommands> elements are two-deep, that a known bug.

respondido 09 mar '12, 23:03

Thanks! Works as expected. I have symlinks to the debug build of the addin in the AddIns directory, so I haven't tried MONODEVELOP_DEV_ADDINS - Simendsjo

@mhutch Cool tip, thanks. Setting MONODEVELOP_DEV_ADDINS works, but only once. Unless I quit all instances of MD, including the instance with the add-in project, only the first compiled add-in will ever be picked up. There's some add-in caching going on? - Roberto Jeppesen

Note, this is on OSX. In Windows it works. Every new compile gets picked up by the newly launched XS - Roberto Jeppesen

TBH I would now suggest using the "Addin Maker" addin which does all this automatically. - mikayla hutchinson

The project I was working on was the F# binding, and your add-in doesn't support F#. - Roberto Jeppesen

the soft debugger doesn't yet support System.Diagnostics.Debugger.Break(), so that won't work.

You just need to debug MonoDevelop inside MonoDevelop and set your breakpoints on the source files of your addin.

respondido 09 mar '12, 22:03

Could you elaborate that? Run > Debug Application > MonoDevelop.exe doesn't do anything.. - Simendsjo

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.