protected override void OnStart(string[] args)
        {
            if (args.Length < 2)
                return;
            Login = args[0];
            Password = args[1];

            var file = new StreamWriter(new FileStream("monitisagent.log",
             System.IO.FileMode.Append));
            try
            {
                file.Write("Starting service");
                var a = new Authentication(Login, Password, null);
                var mon = new MonitisClrMethodInfoAnalizer(a);
                var processor = new ClrActionsProcessor();
                _agent = new Agent(mon, processor);
                file.Write("Started service");
            }
            catch (Exception ex)
            {

                file.Write(ex.ToString());

                throw;
            }
            finally
            {
                file.Close();
            }
        }
 static void Main(string[] args)
 {
     try
     {
         log4net.Config.XmlConfigurator.Configure();
         Log.Info("Starting");
         Environment.SetEnvironmentVariable("COR_ENABLE_PROFILING", "1", EnvironmentVariableTarget.User);
         Environment.SetEnvironmentVariable("COR_PROFILER", "{71EDB19D-4F69-4A2C-A2F5-BE783F543A7E}",
                                            EnvironmentVariableTarget.User);
         var a = new Authentication(Login, Password, null);
         var analizer = new MonitisClrMethodInfoAnalizer(a);
         var agent = new Agent(analizer, new ClrActionsProcessor());
         System.Console.ReadKey();
         agent.Stop();
         Environment.SetEnvironmentVariable("COR_ENABLE_PROFILING", "0", EnvironmentVariableTarget.User);
         Log.Info("Ending");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
 private void InitMonitisProfiler()
 {
     var a = new Authentication(Login, Password, null);
     var mon = new MonitisClrMethodInfoAnalizer(a);
     var processor = new ClrActionsProcessor();
     processor.MessageRecievedEvent += processor_MessageRecievedEvent;
     _agent = new Agent(mon, processor);
 }