[Mono-list] Debugging mono dll loaded by Unity3d

Michael Hutchinson m.j.hutchinson at gmail.com
Sat Jul 17 21:18:44 EDT 2010

On Fri, Jul 16, 2010 at 12:04 PM, and192 <andrew.rushby at googlemail.com> wrote:
> Hi there,
> I have a problem trying to understand how to debug a library I'm writing in
> MonoDevelop. This library is being referenced from a Unity3d project.
> I have been pointing the MonoDevelop debugger at the built Unity3d exe and
> hoping to be able to 'attach' along the lines of the MSVisual studio
> debugger. However the debugger loads in MonoDevelop and encounters an
> exception:
>   System.Runtime.InteropServices.COMException (0x80131700): Failed to load
> the runtime. at
> Microsoft.Samples.Debugging.CorDebug.NativeMethods.GetRequestedRuntimeVersion
> etc...

That's the .NET debugging addin - it cannot debug Mono apps. To use
the Mono debugger, your target runtime should be Mono. However...

> I suspect this is because Unity3d is not a mono executable and the Mono
> debugger cannot detect the runtime version.
> I appreciate there may not be an easy way to do this, but before I give up,
> does anyone have any suggestions, other than writing to debug log files etc,
> on how I can use a debugger to step through my mono code?

The Mono Soft debugger does not support attaching to arbitrary
runtimes. You must use Mono 2.6+, and the apps must be started in
debuggable mode, which MD does automatically using Mono runtime
commandline arguments when starting the app.

For apps that embed the Mono runtime, such as Unity, you need a
(trivial) MD addin to tell it how to launch the app. Also, the
embedding host must support enabling debugging, and must use Mono
2.6+. For this, you'll need Unity 3.0.

Michael Hutchinson

More information about the Mono-list mailing list