Ejemplo n.º 1
0
		/// <summary>
		/// Отображает контрол
		/// </summary>
		/// <param name="Exc">Исключение для отображения.</param>
		/// <param name="parent">Родительский контрол.</param>
		public static void Show(Exception Exc, Control parent)
		{
			ModalErrorBox box = null;
			try
			{
				box = new ModalErrorBox();
				box.flAsm.Text = Exc.Source;
				box.flClass.Text = Exc.TargetSite.DeclaringType.FullName;
				box.flMethod.Text = Exc.TargetSite.ToString();
				box.flErrText.Text = Exc.Message;

				System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(Exc, true);
				for (int a = 0; a < trace.FrameCount; a++)
					if (trace.GetFrame(a).GetFileName() != null)
					{
						box.flFile.Text = System.IO.Path.GetFileName(trace.GetFrame(a).GetFileName());
						box.flLine.Text = trace.GetFrame(a).GetFileLineNumber().ToString();
						break;
					}

				string s = "Стек исключения:\r\n";
				s += trace.ToString();
				s += "\r\nСтек программы:\r\n";
				s += (new System.Diagnostics.StackTrace(1)).ToString();
				s = s.Replace("\t", "").Trim();
				s = s.Replace("at ", "\u2514\u25ba ");
				s = s.Replace("в ", "\u2514\u25ba ");
				box.ftbStack.Text = s; //\u2500

				System.Media.SystemSounds.Exclamation.Play();

				box.Show(parent);
				while (box.isClosed == false)
				{
					if (box.IsDisposed || parent.IsDisposed || box.FindForm() == null)
						break;
					Application.DoEvents();
					System.Threading.Thread.Sleep(50);
				}
			}
			catch
			{
				ErrorBox.Show(Exc);
			}
			finally
			{
				if (box != null)
					box.Dispose();
			}
		}
Ejemplo n.º 2
0
		//-------------------------------------------------------------------------------------
		/// <summary>
		/// Отображает контрол для серверной ошибки
		/// </summary>
		/// <param name="error">Текст ошибки</param>
		/// <param name="parent">Родительский контрол.</param>
		public static void ShowServer(string error, Control parent)
		{
			ModalErrorBox box = null;
			try
			{
				box = new ModalErrorBox();
				box.finistLabelCaption.Text = "Ошибка сервера!";
				box.flErrCaption.Text = "Сервер сообщает:";
				box.fpServMessage.Visible = true;
				box.fpServMessage.Dock = DockStyle.Fill;
				box.fpServMessage.BringToFront();
				box.flErrText.Text = error;
				box.pictureBox1.Image = global::Sim.Controls.Properties.Resources.ErrorServer;
				box.button2.Enabled = false;

				System.Media.SystemSounds.Exclamation.Play();

				box.Show(parent);
				while (box.isClosed == false)
				{
					if (box.IsDisposed || parent.IsDisposed || box.FindForm() == null)
						break;
					Application.DoEvents();
					System.Threading.Thread.Sleep(50);
				}
			}
			catch (Exception err)
			{
				ErrorBox.Show(err);
			}
			finally
			{
				if (box != null)
					box.Dispose();
			}
		}