因为'调试器代理程序:DWP握手失败'错误,不能使用单声道软调试器远程调试
问题描述:
我在我的应用程序中嵌入了单声道。该应用程序是支持插件的控制台应用程序。插件是.NET程序集。所有的工作都很好,但我想调试它们。为了使我的C代码的调试,我有:因为'调试器代理程序:DWP握手失败'错误,不能使用单声道软调试器远程调试
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单运行上面的代码,它就是我对我所做的启用调试。 为了在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握手”中的字符数)。
Anybady知道这个问题吗?
答
问题解决了。麻烦的是在VirtualMachineManager.ListenInternal(2)方法在该行:
dbg_sock.Disconnect (false);
dbg_sock.Close();
出于某种原因,这是未处理的异常(上断开)在这里。 try-catch解决了这个问题。现在一切都很好!