Beispiel #1
0
        public void Start(string targetExe, string initialXaml, string sourceAssembly)
        {
            if (_proc != null)
            {
                _proc.Exited -= OnExited;
                try
                {
                    _comm?.Dispose();
                    _proc.Kill();
                }
                catch { }
                HandleExited();
                State = "Restarting...";
            }

            var msg = new InitMessage(Path.GetFullPath(targetExe), initialXaml, sourceAssembly);
            var exe = typeof(ProcessHost).Assembly.GetModules()[0].FullyQualifiedName;

            _proc = new Process()
            {
                StartInfo = new ProcessStartInfo(exe, "--hosted")
                {
                    UseShellExecute        = false,
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    CreateNoWindow         = true
                },
                EnableRaisingEvents = true
            };
            _proc.Exited += OnExited;
            try
            {
                _proc.Start();
                State            = "Launching designer process...";
                _comm            = new CommChannel(_proc.StandardOutput.BaseStream, _proc.StandardInput.BaseStream);
                _comm.OnMessage += OnMessage;
                _comm.Start();
                _comm.SendMessage(msg);
            }
            catch (Exception e)
            {
                State = e.ToString();
                HandleExited();
            }
            IsAlive = true;
        }
Beispiel #2
0
        public void Start(string targetExe, string initialXaml, string sourceAssembly)
        {
            if (_proc != null)
            {
                _proc.Exited -= OnExited;
                try
                {
                    _comm?.Dispose();
                    _proc.Kill();
                }
                catch { }
                HandleExited();
                State = "Restarting...";
            }

            var msg = new InitMessage(Path.GetFullPath(targetExe), initialXaml, sourceAssembly);
            var exe = typeof (ProcessHost).Assembly.GetModules()[0].FullyQualifiedName;
            _proc = new Process()
            {
                StartInfo = new ProcessStartInfo(exe, "--hosted")
                {
                    UseShellExecute = false,
                    RedirectStandardInput = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true,
                    CreateNoWindow = true
                },
                EnableRaisingEvents = true
            };
            _proc.Exited += OnExited;
            try
            {
                _proc.Start();
                State = "Launching designer process...";
                _comm = new CommChannel(_proc.StandardOutput.BaseStream, _proc.StandardInput.BaseStream);
                _comm.OnMessage += OnMessage;
                _comm.Start();
                _comm.SendMessage(msg);
            }
            catch (Exception e)
            {
                State = e.ToString();
                HandleExited();
            }
            IsAlive = true;

        }