예제 #1
0
        private void InitializeDeployPort()
        {
            m_cbDeployPort.Items.Clear();

            PlatformInfo platformInfo = this.VsProjectFlavorCfg.PlatformInfo;

            foreach (DebugPort port in new DebugPortSupplier().Ports)
            {
                ComboBoxItemPort cbi = new ComboBoxItemPort(port);

                this.m_cbDeployPort.Items.Add(cbi);
            }
        }
        int IVbCompilerHost.GetSdkPath(out string pSdkPath)
        {
            pSdkPath = null;

            //cannot be swapped after load?
            //cannot be determined from active config, at load??
            string frameworkVersion;
            m_innerIVsBuildPropertyStorage.GetPropertyValue(MSBuildProperties.TargetFrameworkVersion, null, (uint)_PersistStorageType.PST_PROJECT_FILE, out frameworkVersion);

            PlatformInfo pi = new PlatformInfo(frameworkVersion);
            pSdkPath = pi.FrameworkAssembliesPath;

            return Utility.COM_HResults.S_OK;   
        }
        int IVbCompilerHost.GetSdkPath(out string pSdkPath)
        {
            pSdkPath = null;

            //cannot be swapped after load?
            //cannot be determined from active config, at load??
            string frameworkVersion;

            m_innerIVsBuildPropertyStorage.GetPropertyValue(MSBuildProperties.TargetFrameworkVersion, null, (uint)_PersistStorageType.PST_PROJECT_FILE, out frameworkVersion);

            PlatformInfo pi = new PlatformInfo(frameworkVersion);

            pSdkPath = pi.FrameworkAssembliesPath;

            return(Utility.COM_HResults.S_OK);
        }
예제 #4
0
        static string[] GetFilesToLoad(string exeToLoad)
        {
            _DBG.PlatformInfo pi          = new Microsoft.SPOT.Debugger.PlatformInfo(null);
            ArrayList         searchPaths = new ArrayList();

            //Goals: build a tree of referenced assemblies.
            //Traverse the tree post-order wise such that all assemblies loaded

            ArrayList listFound = new ArrayList(); // list of Assembly names to avoid dups and an endless loop
            ArrayList results   = new ArrayList(); // ArrayList of Info objects
            Stack     stack     = new Stack();     // stack of Assembly Info objects

            //Should file passed on command-line be searched in AssemblyFolders if not found in current directory?
            string fileName = Path.GetFullPath(exeToLoad);

            //First place to search the folder of the assembly. Then search assembly folders.
            searchPaths.Add(Path.GetDirectoryName(fileName));
            searchPaths.AddRange(pi.AssemblyFolders);

            /* If the file passed isn't a .NET assembly, this next line throws an exception. */
            Assembly a;

            try
            {
                a = Assembly.LoadFile(fileName);   //Always pass full path to LoadFile so it doesn't try to use GAC?
                stack.Push(a.GetName());
                listFound.Add(a.GetName().ToString());
            }
            catch (Exception e)
            {
                throw new ApplicationException("Error: The application selected is not a .NET application.", e);
            }

            while (stack.Count > 0)
            {
                AssemblyName an = (AssemblyName)stack.Pop(); // get next assembly info
                string       dllFile;


                //Does .NET check all search dirs for .dll first then all dirs for .exe or does it
                //search each dir for .dll then .exe, or one of those two with .exe first?
                dllFile = FindFileInPaths(an.Name + ".exe", searchPaths);
                if (!File.Exists(dllFile))
                {
                    dllFile = FindFileInPaths(an.Name + ".dll", searchPaths);
                    if (!File.Exists(dllFile))
                    {
                        throw new FileNotFoundException();
                    }
                }

                string peFile = FullPathToPe(dllFile);
                if (peFile == null)
                {
                    throw new ApplicationException(
                              String.Format("Cannot find PE file for {0}; File is most likely not a .NET Micro Framework assembly.",
                                            dllFile));
                }
                results.Add(peFile);

                AssemblyName[] subchild = Assembly.LoadFile(dllFile).GetReferencedAssemblies();
                for (int i = 0; i < subchild.Length; i++)
                {
                    if (!listFound.Contains(subchild[i].ToString()))
                    {
                        listFound.Add(subchild[i].ToString());
                        stack.Push(subchild[i]);
                    }
                }
            }

            return((string[])results.ToArray(typeof(string)));
        }
예제 #5
0
        public static Process LaunchEmulator(_DBG.PortDefinition_Emulator pd, bool fWaitForDebugger, string program)
        {
            _DBG.PlatformInfo          pi  = new _DBG.PlatformInfo(null);
            _DBG.PlatformInfo.Emulator emu = pi.FindEmulator(pd.Port);

            _DBG.CommandLineBuilder cb = new _DBG.CommandLineBuilder();

            if (emu == null)
            {
                throw new ArgumentException();
            }
            if (emu.legacyCommandLine)
            {
                throw new NotSupportedException("Legacy emulators not supported.");
            }

            if (!string.IsNullOrEmpty(emu.additionalOptions))
            {
                _DBG.CommandLineBuilder cbT = new _DBG.CommandLineBuilder(emu.additionalOptions);
                cb.AddArguments(cbT.Arguments);
            }

            if (!string.IsNullOrEmpty(emu.config))
            {
                cb.AddArguments("/config:" + emu.config);
            }

            if (fWaitForDebugger)
            {
                cb.AddArguments("/waitfordebugger");
            }

            string[] files = EmulatorLauncher.GetFilesToLoad(program);
            foreach (string pe in files)
            {
                cb.AddArguments("/load:" + pe);
            }

            string args = "";

            args = args.Trim();
            if (args.Length > 0)
            {
                cb.AddArguments("/commandlinearguments:" + args);
            }

            string commandLine = cb.ToString();

            commandLine = Environment.ExpandEnvironmentVariables(commandLine);

            Process p = new System.Diagnostics.Process();

            p.StartInfo.FileName         = emu.application;
            p.StartInfo.Arguments        = commandLine;
            p.StartInfo.UseShellExecute  = false;
            p.StartInfo.WorkingDirectory = Path.GetDirectoryName(emu.application);

            try
            {
                p.Start();
            }
            catch (System.ComponentModel.Win32Exception we)
            {
                MessageBox.Show(string.Format("Failed to launch emulator: {0}", we.NativeErrorCode),
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            return(p);
        }
예제 #6
0
        private void InitializeDeployDevice(PortDefinition selected)
        {
            //What about EmulatorExe????

            int       iSelected = -1;
            DebugPort port      = this.SelectedDeployPort;

            if (port == null)
            {
                return;
            }

            PortDefinition[] portDefinitions;

            if (port.IsLocalPort)
            {
                PlatformInfo platformInfo = this.VsProjectFlavorCfg.PlatformInfo;

                PlatformInfo.Emulator[] emulators = platformInfo.Emulators;

                portDefinitions = new PortDefinition[emulators.Length];

                for (int i = 0; i < emulators.Length; i++)
                {
                    portDefinitions[i] = new PlatformInfo.PortDefinition_PeristableEmulator(emulators[i]);
                }
            }
            else
            {
                portDefinitions = port.GetPersistablePortDefinitions();
            }

            m_cbDeployDevice.Items.Clear();

            for (int iPortDefinition = 0; iPortDefinition < portDefinitions.Length; iPortDefinition++)
            {
                PortDefinition pd = portDefinitions[iPortDefinition];

                ComboBoxItemDevice cbi = new ComboBoxItemDevice(pd);
                m_cbDeployDevice.Items.Add(cbi);

                if (Object.Equals(selected, pd))
                {
                    iSelected = m_cbDeployDevice.Items.Count - 1;
                }
            }

            if (m_cbDeployDevice.Items.Count == 0)
            {
                if (selected != null && port.PortFilter == PortFilter.TcpIp && selected is PortDefinition_Tcp)
                {
                    m_cbDeployDevice.Items.Add(new ComboBoxItemDevice(selected));
                }
                else
                {
                    ComboBoxItemDevice cbi = new ComboBoxItemDevice("<none>");
                    m_cbDeployDevice.Items.Insert(0, cbi);
                }
                iSelected = 0;
            }

            if (port.PortFilter != PortFilter.TcpIp)
            {
                iSelected = 0;
            }

            if (iSelected != -1)
            {
                m_cbDeployDevice.SelectedIndex = iSelected;
            }
        }
예제 #7
0
        static string[] GetFilesToLoad(string exeToLoad)
        {
            _DBG.PlatformInfo pi = new Microsoft.SPOT.Debugger.PlatformInfo(null);
            ArrayList searchPaths = new ArrayList();

            //Goals: build a tree of referenced assemblies.
            //Traverse the tree post-order wise such that all assemblies loaded 

            ArrayList listFound = new ArrayList(); // list of Assembly names to avoid dups and an endless loop
            ArrayList results = new ArrayList();   // ArrayList of Info objects
            Stack stack = new Stack(); // stack of Assembly Info objects

            //Should file passed on command-line be searched in AssemblyFolders if not found in current directory?
            string fileName = Path.GetFullPath(exeToLoad);

            //First search the system assemblies, application path may have copies
            searchPaths.AddRange(pi.AssemblyFolders);
            searchPaths.Add(Path.GetDirectoryName(fileName));

            /* If the file passed isn't a .NET assembly, this next line throws an exception. */
            Assembly a;
            try
            {
                a = Assembly.LoadFile(fileName);   //Always pass full path to LoadFile so it doesn't try to use GAC?
                stack.Push(a.GetName());
                listFound.Add(a.GetName().ToString());
            }
            catch (Exception e)
            {
                throw new ApplicationException("Error: The application selected is not a .NET application.", e);
            }

            while (stack.Count > 0)
            {
                AssemblyName an = (AssemblyName)stack.Pop(); // get next assembly info
                string dllFile;


                //Does .NET check all search dirs for .dll first then all dirs for .exe or does it
                //search each dir for .dll then .exe, or one of those two with .exe first?
                dllFile = FindFileInPaths(an.Name + ".exe", searchPaths);
                if (!File.Exists(dllFile))
                {
                    dllFile = FindFileInPaths(an.Name + ".dll", searchPaths);
                    if (!File.Exists(dllFile))
                    {
                        throw new FileNotFoundException("File: " + dllFile);
                    }
                }

                string peFile = FullPathToPe(dllFile);
                if (string.IsNullOrEmpty(peFile))
                {
                    throw new ApplicationException(
                        String.Format("Cannot find PE file for {0}; File is most likely not a .NET Micro Framework assembly.",
                                      dllFile));
                }
                results.Add(peFile);

                AssemblyName[] subchild = Assembly.LoadFile(dllFile).GetReferencedAssemblies();
                for (int i = 0; i < subchild.Length; i++)
                {
                    if (!listFound.Contains(subchild[i].ToString()))
                    {
                        listFound.Add(subchild[i].ToString());
                        stack.Push(subchild[i]);
                    }
                }
            }

            return (string[])results.ToArray(typeof(string));

        }
예제 #8
0
        public static Process LaunchEmulator(_DBG.PortDefinition_Emulator pd, bool fWaitForDebugger, string program)
        {
            _DBG.PlatformInfo pi = new _DBG.PlatformInfo(null);
            _DBG.PlatformInfo.Emulator emu = pi.FindEmulator(pd.Port);

            _DBG.CommandLineBuilder cb = new _DBG.CommandLineBuilder();

            if (emu == null) { throw new ArgumentException(); }
            if (emu.legacyCommandLine) { throw new NotSupportedException("Legacy emulators not supported."); }

            if (!string.IsNullOrEmpty(emu.additionalOptions))
            {
                _DBG.CommandLineBuilder cbT = new _DBG.CommandLineBuilder(emu.additionalOptions);
                cb.AddArguments(cbT.Arguments);
            }

            if (!string.IsNullOrEmpty(emu.config))
            {
                cb.AddArguments("/config:" + emu.config);
            }

            if (fWaitForDebugger)
            {
                cb.AddArguments("/waitfordebugger");
            }

            string[] files = EmulatorLauncher.GetFilesToLoad(program);
            foreach (string pe in files)
            {
                cb.AddArguments("/load:" + pe);
            }

            string args = "";
            args = args.Trim();
            if (args.Length > 0)
            {
                cb.AddArguments("/commandlinearguments:" + args);
            }

            string commandLine = cb.ToString();
            commandLine = Environment.ExpandEnvironmentVariables(commandLine);

            Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = emu.application;
            p.StartInfo.Arguments = commandLine;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.WorkingDirectory = Path.GetDirectoryName(emu.application);

            try
            {
                p.Start();
            }
            catch (System.ComponentModel.Win32Exception we)
            {
                MessageBox.Show(string.Format("Failed to launch emulator: {0}", we.NativeErrorCode),
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }

            return p;
        }
        public void UpdateList()
        {
            ArrayList list = PortDefinition.Enumerate(m_pf);

            #region Code that should probably be in PortDefinition.Enumerate
            {
                bool enumTcpIpPorts = false;
                foreach (PortFilter pf in m_pf)
                {
                    if (pf == PortFilter.TcpIp)
                    {
                        enumTcpIpPorts = true;
                        break;
                    }
                }
                if (enumTcpIpPorts)
                {
                    list.AddRange(EnumerateTcpIpPorts());
                }
            }
            #endregion

            #region Code that could go in PortDefinition.Enumerate if we add a LauncableEmulator port definition. (Or move PersistableEmulator into a non-VS class?
            {
                bool listLaunchableEmulators = false;
                foreach (PortFilter pf in m_pf)
                {
                    if (pf == PortFilter.Emulator)
                    {
                        listLaunchableEmulators = true;
                        break;
                    }
                }

                if (listLaunchableEmulators == true)
                {
                    PlatformInfo pi = new PlatformInfo(null);
                    PlatformInfo.Emulator[] emus = pi.Emulators;

                    foreach (PlatformInfo.Emulator emu in emus)
                    {
                        list.Add(new PortDefinition_Emulator("Launch '" + emu.name + "'", emu.persistableName, 0));
                    }
                }
            }
            #endregion

            object si = SelectedItem;
            base.DataSource = null;
            if (list.Count > 0)
            {
                base.DataSource = list;
                if (list[0] is PortDefinition)
                {
                    base.DisplayMember = "DisplayName";
                }
                if (si != null)
                {
                    SelectedItem = si;
                }
                else
                {
                    base.SelectedIndex = 0;
                }

            }
            else
            {
                base.Text = "<None>";
            }
            base.Update();
        }
예제 #10
0
        private void Connect()
        {
            _DBG.PortDefinition port = comboBoxDevice.PortDefinition;
            if (port == null)
            {
                SetInvalidDevice();
                return;
            }

            try
            {
                comboBoxTransport.Enabled = false;
                comboBoxDevice.Enabled    = false;
                buttonConnect.Enabled     = false;
                groupBoxOutput.Enabled    = false;
                groupBoxOptions.Enabled   = false;
                m_state = ProfilingState.Connecting;

                if (port is _DBG.PortDefinition_Emulator)
                {
                    _DBG.PortDefinition_Emulator emuport = port as _DBG.PortDefinition_Emulator;
                    if (emuport.Pid == 0)
                    {
                        OpenFileDialog fd = new OpenFileDialog();
                        fd.DefaultExt = "exe";
                        fd.Filter     = ".NET MF Exe files (*.exe)|*.exe";
                        fd.Title      = "Choose an application to emulate";
                        if (fd.ShowDialog(this) == DialogResult.OK)
                        {
                            m_emuProcess = EmulatorLauncher.LaunchEmulator(emuport, true, fd.FileName);
                            if (m_emuProcess == null)
                            {
                                LogText("Could not launch emulator.");
                                Disconnect();
                                return;
                            }
                            else
                            {
                                m_emuLaunched = true;
                                LogText(string.Format("Started emulator process {0}", m_emuProcess.Id));

                                _DBG.PlatformInfo pi = new _DBG.PlatformInfo(null);
                                port = new _DBG.PortDefinition_Emulator("Emulator - pid " + m_emuProcess.Id, m_emuProcess.Id);
                                comboBoxDevice.SelectLaunchedEmulator((_DBG.PortDefinition_Emulator)port);
                            }
                        }
                        else
                        {
                            Disconnect();
                            return;
                        }
                    }
                    else
                    {
                        try
                        {
                            m_emuProcess = Process.GetProcessById(emuport.Pid);
                        }
                        catch
                        {
                            m_state = ProfilingState.Disconnected;
                            EnableUI();
                            SetInvalidDevice();
                            return;
                        }
                    }
                }

                buttonConnect.Text    = c_Cancel;
                buttonConnect.Enabled = true;
                BackgroundConnectorArguments bca = new BackgroundConnectorArguments();
                bca.connectPort    = port;
                bca.outputFileName = textLogFile.Text;
#if DEBUG
                if (radioOffProf.Checked)
                {
                    bca.exporter = BackgroundConnectorArguments.ExporterType.OffProf;
                }
                else
                {
                    bca.exporter = BackgroundConnectorArguments.ExporterType.CLRProfiler;
                }
#else
                bca.exporter = BackgroundConnectorArguments.ExporterType.CLRProfiler;
#endif

                //Rebooting the emulator just makes it quit.
                bca.reboot = checkReboot.Checked && !(port is _DBG.PortDefinition_Emulator);

                bwConnecter.RunWorkerAsync(bca);
            }
            catch (ApplicationException e)
            {
                comboBoxTransport.Enabled = true;
                comboBoxDevice.Enabled    = true;
                buttonConnect.Enabled     = true;
                groupBoxOutput.Enabled    = true;
                groupBoxOptions.Enabled   = true;
                m_state = ProfilingState.Disconnected;

                MessageBox.Show(this, e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #11
0
        private void LoadAssemblies()
        {
            VsPackage.MessageCentre.DebugMsg(DiagnosticStrings.LoadAssemblies);

            WireProtocol.Commands.Debugging_Resolve_Assembly[] assemblies = Engine.ResolveAllAssemblies();
            string[] assemblyPathsT = new string[1];
            Pdbx.PdbxFile.Resolver resolver = new Pdbx.PdbxFile.Resolver();

            if (!m_fLaunched || !this.IsLocalWin32Process)
            {
                //Find mscorlib
                WireProtocol.Commands.Debugging_Resolve_Assembly a = null;
                WireProtocol.Commands.Debugging_Resolve_Assembly.Reply reply = null;

                for (int i = 0; i < assemblies.Length; i++)
                {
                    a = assemblies[i];
                    reply = a.m_reply;

                    if (reply.Name == "mscorlib")
                        break;
                }

                DebugAssert(reply.Name == "mscorlib");

                //Add assemblyDirectories
                string asyVersion = "v4.3";
                if(AssemblyPaths != null)
                {
                    Regex versionExpr = new Regex(@"\\(v[\d]+\.[\d]+)\\");
                    for(int i=0; i<AssemblyPaths.Length; i++)
                    {
                        Match m = versionExpr.Match(AssemblyPaths[i]);

                        if (m.Success)
                        {
                            asyVersion = m.Groups[1].Value;
                            break;
                        }
                    }
                }

                PlatformInfo platformInfo = new PlatformInfo(asyVersion); // by not spcifying any runtime information, we will look for the most suitable version
                resolver.AssemblyDirectories = platformInfo.AssemblyFolders;
            }

            for(int i = 0; i < assemblies.Length; i++)
            {
                WireProtocol.Commands.Debugging_Resolve_Assembly a = assemblies[i];

                CorDebugAssembly assembly = this.AssemblyFromIdx( a.m_idx );

                if(assembly == null)
                {
                    WireProtocol.Commands.Debugging_Resolve_Assembly.Reply reply = a.m_reply;

                    if (!string.IsNullOrEmpty(reply.Path))
                    {
                        assemblyPathsT[0] = reply.Path;

                        resolver.AssemblyPaths = assemblyPathsT;
                    }
                    else
                    {
                        resolver.AssemblyPaths = m_assemblyPaths;
                    }

                    Pdbx.PdbxFile pdbxFile = resolver.Resolve(reply.Name, reply.m_version, Engine.IsTargetBigEndian); //Pdbx.PdbxFile.Open(reply.Name, reply.m_version, assemblyPaths);

                    assembly = new CorDebugAssembly(this, reply.Name, pdbxFile, TinyCLR_TypeSystem.IdxAssemblyFromIndex(a.m_idx));

                    m_assemblies.Add( assembly );
                }
            }
        }
예제 #12
0
        internal static PortDefinition GetPort(string device, string transport, string exePath)
        {
            PortFilter[] args = { };
            switch (transport.ToLower())
            {
                case "emulator":
                    args = new PortFilter[] { PortFilter.Emulator };
                    device = "emulator";
                    PortDefinition pd = 
                        PortDefinition.CreateInstanceForEmulator("Launch 'Microsoft Emulator'", "Microsoft", 0);

                    PlatformInfo pi = new PlatformInfo(null);
                    PlatformInfo.Emulator emu = pi.FindEmulator(pd.Port);

                    if (emu != null)
                    {
                        string onboardFlash = Path.Combine(Path.GetDirectoryName(emu.application), "OnBoardFlash.dat");

                        if (File.Exists(onboardFlash))
                        {
                            try
                            {
                                File.Delete(onboardFlash);
                            }
                            catch
                            {
                            }
                        }
                    }


                    PortDefinition_Emulator emuport = pd as PortDefinition_Emulator;
                    Console.WriteLine("\tLaunching Emulator..");
                    Process emuProc = EmulatorLauncher.LaunchEmulator(
                        emuport,
                        true, exePath);
                    break;
                case "serial":
                    args = new PortFilter[] { PortFilter.Serial };
                    break;
                case "tcpip":
                    args = new PortFilter[] { PortFilter.TcpIp };
                    break;
                case "usb":
                    args = new PortFilter[] { PortFilter.Usb };
                    break;
            }

            ArrayList list = new ArrayList();
            int nRetries = 20;

            while (list.Count == 0 && nRetries-- > 0)
            {
                list = PortDefinition.Enumerate(args);

                if (list.Count > 0) break;

                System.Threading.Thread.Sleep(500);
            }

            PortDefinition port = null;

            foreach (object prt in list)
            {
                port = (PortDefinition)prt;
                if (port.DisplayName.ToLower().Contains(device.ToLower()))
                {
                    break;
                }
                else
                {
                    port = null;
                }
            }

            if (null != port)
            {
                return port;
            }
            else
            {
                throw new ApplicationException(
                    "Could not find the specified device for the harness to connect to.");
            }
        }
        private void Connect()
        {
            _DBG.PortDefinition port = comboBoxDevice.PortDefinition;
            if (port == null)
            {
                SetInvalidDevice();
                return;
            }

            try
            {
                comboBoxTransport.Enabled = false;
                comboBoxDevice.Enabled = false;
                buttonConnect.Enabled = false;
                groupBoxOutput.Enabled = false;
                groupBoxOptions.Enabled = false;
                m_state = ProfilingState.Connecting;

                if (port is _DBG.PortDefinition_Emulator)
                {
                    _DBG.PortDefinition_Emulator emuport = port as _DBG.PortDefinition_Emulator;
                    if (emuport.Pid == 0)
                    {
                        OpenFileDialog fd = new OpenFileDialog();
                        fd.DefaultExt = "exe";
                        fd.Filter = ".NET MF Exe files (*.exe)|*.exe";
                        fd.Title = "Choose an application to emulate";
                        if (fd.ShowDialog(this) == DialogResult.OK)
                        {
                            m_emuProcess = EmulatorLauncher.LaunchEmulator(emuport, true, fd.FileName);
                            if (m_emuProcess == null)
                            {
                                LogText("Could not launch emulator.");
                                Disconnect();
                                return;
                            }
                            else
                            {
                                m_emuLaunched = true;
                                LogText(string.Format("Started emulator process {0}", m_emuProcess.Id));

                                _DBG.PlatformInfo pi = new _DBG.PlatformInfo(null);
                                port = new _DBG.PortDefinition_Emulator("Emulator - pid " + m_emuProcess.Id, m_emuProcess.Id);
                                comboBoxDevice.SelectLaunchedEmulator((_DBG.PortDefinition_Emulator)port);
                            }
                        }
                        else
                        {
                            Disconnect();
                            return;
                        }
                    }
                    else
                    {
                        try
                        {
                            m_emuProcess = Process.GetProcessById(emuport.Pid);
                        }
                        catch
                        {
                            m_state = ProfilingState.Disconnected;
                            EnableUI();
                            SetInvalidDevice();
                            return;
                        }
                    }
                }

                buttonConnect.Text = c_Cancel;
                buttonConnect.Enabled = true;
                BackgroundConnectorArguments bca = new BackgroundConnectorArguments();
                bca.connectPort = port;
                bca.outputFileName = textLogFile.Text;
#if DEBUG
            if (radioOffProf.Checked)
            {
                bca.exporter = BackgroundConnectorArguments.ExporterType.OffProf;
            }
            else
            {
                bca.exporter = BackgroundConnectorArguments.ExporterType.CLRProfiler;
            }
#else
                bca.exporter = BackgroundConnectorArguments.ExporterType.CLRProfiler;
#endif

                //Rebooting the emulator just makes it quit.
                bca.reboot = checkReboot.Checked && !(port is _DBG.PortDefinition_Emulator);

                bwConnecter.RunWorkerAsync(bca);
            }
            catch (ApplicationException e)
            {
                comboBoxTransport.Enabled = true;
                comboBoxDevice.Enabled = true;
                buttonConnect.Enabled = true;
                groupBoxOutput.Enabled = true;
                groupBoxOptions.Enabled = true;
                m_state = ProfilingState.Disconnected;

                MessageBox.Show(this, e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }