无法使用 Mono Soft Debugger 远程调试,因为“调试器代理:DWP 握手失败"错误 [英] Can't use Mono Soft Debugger Remote Debugging because 'debugger-agent: DWP handshake failed' error

查看:21
本文介绍了无法使用 Mono Soft Debugger 远程调试,因为“调试器代理:DWP 握手失败"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中嵌入了单声道.该应用程序是支持插件的控制台应用程序.插件是 .NET 程序集.一切都很好,但我想调试它们.要在我的 C 代码中启用调试,我有:

I've embedded mono in my application. The application is console application that supports plug-ins. Plug-ins are .NET assemblies. All work great, but i want to debug them. To enable debugging in my C-code i have:

mono_set_dirs (ASSEMBLIES_DIR_NAME, ASSEMBLIES_DIR_NAME);
assembly_add_to_bundle(API_ASSEMBLY);

soft_debug = getenv("MYAPP_SOFT_DEBUG");
if (soft_debug != NULL) {
   char *options; 
   options = malloc(17 + strlen(soft_debug));
   sprintf(options, "--debugger-agent=%s", soft_debug); 

   mono_jit_parse_options (1, &options); 
   free (options); 

   mono_debug_init (MONO_DEBUG_FORMAT_MONO);
}

domain = JIT_INIT();

...

上面的代码启动了单声道运行时,这就是我为启用调试所做的一切.为了在 MonoDevelop 端启用调试,我创建了一个插件并实现了必要的类.启动调试的那个是从 RemoteSoftDebuggerSession 派生的.这是我的 OnRun 方法:

The code above inits mono runtime and it's all i've done to enable debugging. To enable debugging at MonoDevelop side i've created an Add-in and implemented necessary classes. The one that starts debugging is derived from RemoteSoftDebuggerSession. Here is my OnRun method:

protected override void OnRun (DebuggerStartInfo startInfo)
{
   var dsi = (MyAppDebuggerStartInfo) startInfo;
   var procStartInfo = new ProcessStartInfo(@"C:MyAppmyapp.exe") {                
    UseShellExecute = false,
    RedirectStandardOutput = true,
    RedirectStandardError = true,
    WorkingDirectory = @"C:MyApp",
    Arguments = dsi.AppName
   };

   procStartInfo.EnvironmentVariables.Add("MYAPP_SOFT_DEBUG",                       
      String.Format("transport=dt_socket,address={0}:{1}", 
         dsi.Address, dsi.DebugPort));

   this._myapp = Process.Start(procStartInfo);
   this._runner.EnableRaisingEvents = true;
   base.ConnectOutput(this._runner.StandardOutput, false);
   base.ConnectOutput(this._runner.StandardError, true);

   this._runner.Exited += delegate { this.EndSession(); };
   base.StartListening(dsi);
}

问题是当我开始调试 myapp 打印调试器代理:DWP 握手失败"并且调试结束时.我能弄清楚的是,恰好 13 个字节被发送到 myapp.exe 并收到了 13 个字节(DWP-Handshake"中的字符数).

The problem is when i start debugging myapp prints "debugger-agent: DWP handshake failed" and debugging ends. All i could figure out is that exactly 13 bytes are sent to myapp.exe and 13 bytes are recieved (the number of chars in "DWP-Handshake").

有人知道这个问题吗?

推荐答案

问题解决了.问题出在 VirtualMachineManager.ListenInternal(2) 方法中:

Problem is solved. The trouble was in VirtualMachineManager.ListenInternal(2) method in this lines:

dbg_sock.Disconnect (false);
dbg_sock.Close ();

由于某种原因,这里是未处理的异常(断开连接).try-catch 解决了这个问题.现在一切正常!

For some reason it was unhandled exception (on Disconnect) here. try-catch solved the problem. Now all works great!

这篇关于无法使用 Mono Soft Debugger 远程调试,因为“调试器代理:DWP 握手失败"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆