internal async Task AttachDebugger(string ipAddress)
        {
            string path = GetStartupAssemblyPath();
            string targetExe = Path.GetFileName(path);
            string outputDirectory = Path.GetDirectoryName(path);

            Project startup = GetStartupProject();

            bool isWeb = ((object[]) startup.ExtenderNames).Any(x => x.ToString() == "WebApplication");
            ApplicationType appType = isWeb ? ApplicationType.Webapplication : ApplicationType.Desktopapplication;
            if (appType == ApplicationType.Webapplication)
                outputDirectory += @"\..\..\";

            var client = new DebugClient(appType, targetExe, outputDirectory);
            DebugSession session = await client.ConnectToServerAsync(ipAddress);
            await session.TransferFilesAsync();
            await session.WaitForAnswerAsync();

            IntPtr pInfo = GetDebugInfo(ipAddress, targetExe, outputDirectory);
            var sp = new ServiceProvider((IServiceProvider) _dte);
            try
            {
                var dbg = (IVsDebugger) sp.GetService(typeof (SVsShellDebugger));
                int hr = dbg.LaunchDebugTargets(1, pInfo);
                Marshal.ThrowExceptionForHR(hr);

                DebuggedMonoProcess.Instance.AssociateDebugSession(session);
            }
            catch(Exception ex)
            {
                logger.Error(ex);
                string msg;
                var sh = (IVsUIShell) sp.GetService(typeof (SVsUIShell));
                sh.GetErrorInfo(out msg);

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    logger.Error(msg);
                }
                throw;
            }
            finally
            {
                if (pInfo != IntPtr.Zero)
                    Marshal.FreeCoTaskMem(pInfo);
            }
        }
示例#2
0
 public DebugSession(DebugClient debugClient, ApplicationType type, Socket socket)
 {
     Client = debugClient;
     this.type = type;
     communication = new TcpCommunication(socket);
 }
示例#3
0
 public DebugSession(DebugClient debugClient, ApplicationType type, Socket socket)
 {
     Client        = debugClient;
     this.type     = type;
     communication = new TcpCommunication(socket);
 }