Example #1
0
        public static void Run(string[] args)
        {
            try
            {
                // Load n-refactory from MD's dir
                string path = typeof(Mono.Debugging.Client.DebuggerSession).Assembly.Location;
                path = System.IO.Path.GetDirectoryName(path);
                path = System.IO.Path.Combine(path, "NRefactory.dll");
                Assembly.LoadFrom(path);

                string channel = Console.In.ReadLine();

                string unixPath = null;
                if (channel == "unix")
                {
                    unixPath = System.IO.Path.GetTempFileName();
                    Hashtable props = new Hashtable();
                    props["path"] = unixPath;
                    props["name"] = "__internal_unix";
                    ChannelServices.RegisterChannel(new UnixChannel(props, null, null), false);
                }
                else
                {
                    Hashtable props = new Hashtable();
                    props["port"] = 0;
                    props["name"] = "__internal_tcp";
                    BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
                    BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();

                    serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
                    ChannelServices.RegisterChannel(new TcpChannel(props, clientProvider, serverProvider), false);
                }

                string sref = Console.In.ReadLine();
                byte[] data = Convert.FromBase64String(sref);

                MemoryStream        ms = new MemoryStream(data);
                BinaryFormatter     bf = new BinaryFormatter();
                IDebuggerController dc = (IDebuggerController)bf.Deserialize(ms);

                Instance = new DebuggerServer(dc);
                dc.RegisterDebugger(Instance);
                try
                {
                    dc.WaitForExit();
                }
                catch (Exception e)
                {
                    Console.WriteLine("DS: Exception while waiting for WaitForExit: {0}", e.ToString());
                }

                try
                {
                    Instance.Dispose();
                }
                catch
                {
                }

                if (unixPath != null)
                {
                    File.Delete(unixPath);
                }
            } catch (Exception e)
            {
                Console.WriteLine("DS: {0}", e.ToString());
            }

            // Delay the exit a few seconds, to make sure all remoting calls
            // from the client have been completed
            System.Threading.Thread.Sleep(3000);

            Console.WriteLine("DebuggerServer exiting.");
        }
		public static void Run (string[] args)
		{
			try
			{
				// Load n-refactory from MD's dir
				string path = typeof(Mono.Debugging.Client.DebuggerSession).Assembly.Location;
				path = System.IO.Path.GetDirectoryName (path);
				path = System.IO.Path.Combine (path, "NRefactory.dll");
				Assembly.LoadFrom (path);
				
				string channel = Console.In.ReadLine();

				string unixPath = null;
				if (channel == "unix")
				{
					unixPath = System.IO.Path.GetTempFileName();
					Hashtable props = new Hashtable();
					props["path"] = unixPath;
					props["name"] = "__internal_unix";
					ChannelServices.RegisterChannel(new UnixChannel(props, null, null), false);
				}
				else
				{
					Hashtable props = new Hashtable();
					props["port"] = 0;
					props["name"] = "__internal_tcp";
					BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
					BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();

					serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
					ChannelServices.RegisterChannel(new TcpChannel(props, clientProvider, serverProvider), false);
				}

				string sref = Console.In.ReadLine();
				byte[] data = Convert.FromBase64String(sref);
				
				MemoryStream ms = new MemoryStream(data);
				BinaryFormatter bf = new BinaryFormatter();
				IDebuggerController dc = (IDebuggerController) bf.Deserialize(ms);

				Instance = new DebuggerServer(dc);
				dc.RegisterDebugger (Instance);
				try
				{
					dc.WaitForExit();
				}
				catch (Exception e)
				{
					Console.WriteLine ("DS: Exception while waiting for WaitForExit: {0}", e.ToString ());
				}

				try
				{
					Instance.Dispose();
				}
				catch
				{
				}

				if (unixPath != null)
					File.Delete(unixPath);
				
			} catch (Exception e)
			{
				Console.WriteLine ("DS: {0}", e.ToString());
			}
			
			// Delay the exit a few seconds, to make sure all remoting calls
			// from the client have been completed
			System.Threading.Thread.Sleep (3000);

			Console.WriteLine ("DebuggerServer exiting.");
		}