C# Can';t使用Mono Soft Debugger远程调试,因为';调试器代理:DWP握手失败';错误

C# Can';t使用Mono Soft Debugger远程调试,因为';调试器代理:DWP握手失败';错误,c#,.net,debugging,mono,monodevelop,C#,.net,Debugging,Mono,Monodevelop,我已经在我的应用程序中嵌入了mono。该应用程序是支持插件的控制台应用程序。插件是.NET程序集。所有的工作都很好,但我想调试它们。要在我的C代码中启用调试,我有: 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) {

我已经在我的应用程序中嵌入了mono。该应用程序是支持插件的控制台应用程序。插件是.NET程序集。所有的工作都很好,但我想调试它们。要在我的C代码中启用调试,我有:

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();

...
上面的代码是inits mono运行时,这是我为启用调试所做的全部工作。 为了在MonoDevelop端启用调试,我创建了一个外接程序并实现了必要的类。启动调试的源于RemoteSoftDebuggerSession。以下是我的OnRun方法:

protected override void OnRun (DebuggerStartInfo startInfo)
{
   var dsi = (MyAppDebuggerStartInfo) startInfo;
   var procStartInfo = new ProcessStartInfo(@"C:\MyApp\myapp.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握手”中的字符数)


有人知道这个问题吗?

问题解决了。问题出在VirtualMachineManager中。这行中的ListenInternal(2)方法:

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

由于某种原因,这里出现了未处理的异常(断开连接时)。试着抓住解决了这个问题。现在一切都很好

问题解决了。问题出在VirtualMachineManager中。这行中的ListenInternal(2)方法:

dbg_sock.Disconnect (false);
dbg_sock.Close ();
由于某种原因,这里出现了未处理的异常(断开连接时)。试着抓住解决了这个问题。现在一切都很好