public static object ServerTransport(StreamWrapper stream) { Tracker.TrackPageview("transports", "server"); var userId = stream.UserId; Core.Credentials.Account account; account = AccountManager.GetAccounts().FirstOrDefault(a => a.userInfo.id == userId); Exception error = null; if (account == null) { // Get the default account account = AccountManager.GetAccounts(stream.ServerUrl).FirstOrDefault(); error = new WarningException( "Original account not found. Please make sure you have permissions to access this stream!"); if (account == null) { // No default error = new WarningException( $"No account found for {stream.ServerUrl}."); } } if (error != null) { throw error; } return(new ServerTransport(account, stream.StreamId)); }
static void Main(string[] args) { //<snippet1> WarningException myEx = new WarningException("This is a warning"); Console.WriteLine(myEx.Message); Console.WriteLine(myEx.ToString()); //</snippet1> }
void LogWarning(string errorMessage) { #if Unity_Editor || UNITY_STANDALONE Debug.LogWarning(errorMessage); #else WarningException myEx = new WarningException(errorMessage); Console.Write(myEx.ToString()); #endif }
public void Ctor_String_String_String(string message, string helpUrl, string helpTopic) { var exception = new WarningException(message, helpUrl, helpTopic); Assert.Null(exception.InnerException); Assert.Equal(helpTopic, exception.HelpTopic); Assert.Equal(helpUrl, exception.HelpUrl); Assert.Equal(-2146233087, exception.HResult); Assert.Equal(message, exception.Message); }
public void Ctor_Default() { var exception = new WarningException(); Assert.Null(exception.InnerException); Assert.Null(exception.HelpTopic); Assert.Null(exception.HelpUrl); Assert.Equal(-2146233087, exception.HResult); Assert.NotEmpty(exception.Message); }
public void Ctor_String_Exception(string message) { var innerException = new DivideByZeroException(); var exception = new WarningException(message, innerException); Assert.Same(innerException, exception.InnerException); Assert.Null(exception.HelpTopic); Assert.Null(exception.HelpUrl); Assert.Equal(-2146233087, exception.HResult); Assert.Equal(message, exception.Message); }
public void ThrowsExceptionOnAmbiguousConfigFileLocation(string repoConfigFile, string workingConfigFile) { var repositoryConfigFilePath = SetupConfigFileContent(string.Empty, repoConfigFile, repoPath); var workingDirectoryConfigFilePath = SetupConfigFileContent(string.Empty, workingConfigFile, workingPath); WarningException exception = Should.Throw <WarningException>(() => { configFileLocator.Verify(workingPath, repoPath, fileSystem); }); var expecedMessage = string.Format("Ambiguous config file selection from '{0}' and '{1}'", workingDirectoryConfigFilePath, repositoryConfigFilePath); exception.Message.ShouldBe(expecedMessage); }
public static void WriteWarningException(string message, WarningException err = null) { Write(string.Format($"Warning: {message}")); if (err != null) { throw new WarningException(message, err); } else { throw new WarningException(message); } }
/// <summary> /// 调用方法 /// </summary> /// <param name="args"></param> public void Call(CallEventArgs args) { //计数按方法 var thisKey = string.Format("{0}${1}${2}${3}", args.Caller.AppName, args.Caller.ServiceName, args.Caller.MethodName, args.Caller.Parameters); var callKey = IoCHelper.GetMD5String(thisKey); lock (hashtable.SyncRoot) { if (!hashtable.ContainsKey(callKey)) { var counterInfo = new CounterInfo { AppName = args.Caller.AppName, ServiceName = args.Caller.ServiceName, MethodName = args.Caller.MethodName, Parameters = args.Caller.Parameters, NeedReset = false, Count = 1 }; hashtable[callKey] = counterInfo; return; } } var counter = hashtable[callKey] as CounterInfo; if (counter.NeedReset) { //重置计数器 hashtable.Remove(callKey); //如果调用次数超过最大允许数,则提示警告 if (counter.Count >= maxCount) { var warning = new WarningException(string.Format("【{0}】 One minute call service ({1}, {2}) {3} times more than {4} times.\r\nParameters => {5}", counter.AppName, counter.ServiceName, counter.MethodName, counter.Count, maxCount, counter.Parameters)); //内部异常 var error = new IoCException(string.Format("【{0}】 One minute call service ({1}) {2} times.", counter.AppName, counter.ServiceName, counter.Count), warning); //抛出异常 args.Error = error; } } else { //计数器加1 counter.Count++; } }
internal static Mesh MTDMeshFromMayaMesh(MFnMesh mayaMesh, MSpace.Space space) { PointList vertices = new PointList(mayaMesh.numVertices); ; List <IndexGroup> faceIndexList = new List <IndexGroup>(mayaMesh.numPolygons); MPointArray mayaVerts = new MPointArray(); mayaMesh.getPoints(mayaVerts, space); if (MGlobal.isYAxisUp) { vertices.AddRange(mayaVerts.Select(v => Point.ByCoordinates(v.x, -v.z, v.y))); } else { vertices.AddRange(mayaVerts.Select(v => Point.ByCoordinates(v.x, v.y, v.z))); } MIntArray faceIndex = new MIntArray(); for (int i = 0; i < mayaMesh.numPolygons; i++) { mayaMesh.getPolygonVertices(i, faceIndex); if (faceIndex.length > 4) { WarningException wa = new WarningException("The DynMesh will not show in Dynamo if it has any faces with 4 verts or more. The DynMesh can be represented as closed curves ."); return(null); } if (faceIndex.length == 3) { faceIndexList.Add(IndexGroup.ByIndices((uint)faceIndex[0], (uint)faceIndex[1], (uint)faceIndex[2])); } else { faceIndexList.Add(IndexGroup.ByIndices((uint)faceIndex[0], (uint)faceIndex[1], (uint)faceIndex[2], (uint)faceIndex[3])); } } mayaMesh.Dispose(); mayaVerts.Dispose(); faceIndex.Dispose(); using (vertices) { return(Mesh.ByPointsFaceIndices(vertices, faceIndexList)); } }
public void TestComponentModel() { WarningException we = new WarningException("a message"); we = new WarningException(null); AreEqual(EditorBrowsableState.Advanced.ToString(), "Advanced"); EditorBrowsableAttribute eba = new EditorBrowsableAttribute(EditorBrowsableState.Advanced); Assert(eba.GetType().IsSubclassOf(typeof(System.Attribute))); #if !SILVERLIGHT //SilverlightProxies.cs does not define the State property AreEqual(eba.State, EditorBrowsableState.Advanced); #endif }
public static void LogWarning(WarningException warning) { string message = string.Format("Time: {0}", DateTime.UtcNow.ToString("dd/MM/yyyy hh:mm:ss tt")); message += Environment.NewLine; message += "-----------------------------------------------------------"; message += Environment.NewLine; message += string.Format("HelpTopic: {0}", warning.HelpTopic); message += Environment.NewLine; message += string.Format("HelpUrl: {0}", warning.HelpUrl); message += Environment.NewLine; message += "-----------------------------------------------------------"; message += Environment.NewLine; Log(message, LogLevel.Warning); }
/// <summary> /// Initializes a new instance of the <see cref='System.Windows.Forms.ThreadExceptionDialog'/> class. /// </summary> public ThreadExceptionDialog(Exception t) { if (DpiHelper.IsScalingRequirementMet) { scaledMaxWidth = LogicalToDeviceUnits(MAXWIDTH); scaledMaxHeight = LogicalToDeviceUnits(MAXHEIGHT); scaledPaddingWidth = LogicalToDeviceUnits(PADDINGWIDTH); scaledPaddingHeight = LogicalToDeviceUnits(PADDINGHEIGHT); scaledMaxTextWidth = LogicalToDeviceUnits(MAXTEXTWIDTH); scaledMaxTextHeight = LogicalToDeviceUnits(MAXTEXTHEIGHT); scaledButtonTopPadding = LogicalToDeviceUnits(BUTTONTOPPADDING); scaledButtonDetailsLeftPadding = LogicalToDeviceUnits(BUTTONDETAILS_LEFTPADDING); scaledMessageTopPadding = LogicalToDeviceUnits(MESSAGE_TOPPADDING); scaledHeightPadding = LogicalToDeviceUnits(HEIGHTPADDING); scaledButtonWidth = LogicalToDeviceUnits(BUTTONWIDTH); scaledButtonHeight = LogicalToDeviceUnits(BUTTONHEIGHT); scaledButtonAlignmentWidth = LogicalToDeviceUnits(BUTTONALIGNMENTWIDTH); scaledButtonAlignmentPadding = LogicalToDeviceUnits(BUTTONALIGNMENTPADDING); scaledDetailsWidthPadding = LogicalToDeviceUnits(DETAILSWIDTHPADDING); scaledDetailsHeight = LogicalToDeviceUnits(DETAILSHEIGHT); scaledPictureWidth = LogicalToDeviceUnits(PICTUREWIDTH); scaledPictureHeight = LogicalToDeviceUnits(PICTUREHEIGHT); scaledExceptionMessageVerticalPadding = LogicalToDeviceUnits(EXCEPTIONMESSAGEVERTICALPADDING); } string messageFormat; string messageText; Button[] buttons; bool detailAnchor = false; WarningException w = t as WarningException; if (w != null) { messageFormat = SR.ExDlgWarningText; messageText = w.Message; if (w.HelpUrl == null) { buttons = new Button[] { continueButton }; } else { buttons = new Button[] { continueButton, helpButton }; } } else { messageText = t.Message; detailAnchor = true; if (Application.AllowQuit) { if (t is System.Security.SecurityException) { messageFormat = SR.ExDlgSecurityErrorText; } else { messageFormat = SR.ExDlgErrorText; } buttons = new Button[] { detailsButton, continueButton, quitButton }; } else { if (t is System.Security.SecurityException) { messageFormat = SR.ExDlgSecurityContinueErrorText; } else { messageFormat = SR.ExDlgContinueErrorText; } buttons = new Button[] { detailsButton, continueButton }; } } if (messageText.Length == 0) { messageText = t.GetType().Name; } if (t is System.Security.SecurityException) { messageText = string.Format(messageFormat, t.GetType().Name, Trim(messageText)); } else { messageText = string.Format(messageFormat, Trim(messageText)); } StringBuilder detailsTextBuilder = new StringBuilder(); string newline = "\r\n"; string separator = SR.ExDlgMsgSeperator; string sectionseparator = SR.ExDlgMsgSectionSeperator; if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.ExDlgMsgHeaderNonSwitchable); } else { detailsTextBuilder.Append(SR.ExDlgMsgHeaderSwitchable); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.ExDlgMsgExceptionSection)); detailsTextBuilder.Append(t.ToString()); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.ExDlgMsgLoadedAssembliesSection)); foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { AssemblyName name = asm.GetName(); string fileVer = SR.NotAvailable; try { if (name.EscapedCodeBase != null && name.EscapedCodeBase.Length > 0) { Uri codeBase = new Uri(name.EscapedCodeBase); if (codeBase.Scheme == "file") { fileVer = FileVersionInfo.GetVersionInfo(NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion; } } } catch (System.IO.FileNotFoundException) { } detailsTextBuilder.Append(string.Format(SR.ExDlgMsgLoadedAssembliesEntry, name.Name, name.Version, fileVer, name.EscapedCodeBase)); detailsTextBuilder.Append(separator); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.ExDlgMsgJITDebuggingSection)); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.ExDlgMsgFooterNonSwitchable); } else { detailsTextBuilder.Append(SR.ExDlgMsgFooterSwitchable); } detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); string detailsText = detailsTextBuilder.ToString(); Graphics g = message.CreateGraphicsInternal(); Size textSize = new Size(scaledMaxWidth - scaledPaddingWidth, int.MaxValue); if (DpiHelper.IsScalingRequirementMet && Label.UseCompatibleTextRenderingDefault == false) { // we need to measure string using API that matches the rendering engine - TextRenderer.MeasureText for GDI textSize = Size.Ceiling(TextRenderer.MeasureText(messageText, Font, textSize, TextFormatFlags.WordBreak)); } else { // if HighDpi improvements are not enabled, or rendering mode is GDI+, use Graphics.MeasureString textSize = Size.Ceiling(g.MeasureString(messageText, Font, textSize.Width)); } textSize.Height += scaledExceptionMessageVerticalPadding; g.Dispose(); if (textSize.Width < scaledMaxTextWidth) { textSize.Width = scaledMaxTextWidth; } if (textSize.Height > scaledMaxHeight) { textSize.Height = scaledMaxHeight; } int width = textSize.Width + scaledPaddingWidth; int buttonTop = Math.Max(textSize.Height, scaledMaxTextHeight) + scaledPaddingHeight; Form activeForm = Form.ActiveForm; if (activeForm == null || activeForm.Text.Length == 0) { Text = SR.ExDlgCaption; } else { Text = string.Format(SR.ExDlgCaption2, activeForm.Text); } AcceptButton = continueButton; CancelButton = continueButton; FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; MinimizeBox = false; StartPosition = FormStartPosition.CenterScreen; Icon = null; ClientSize = new Size(width, buttonTop + scaledButtonTopPadding); TopMost = true; pictureBox.Location = new Point(scaledPictureWidth / 8, scaledPictureHeight / 8); pictureBox.Size = new Size(scaledPictureWidth * 3 / 4, scaledPictureHeight * 3 / 4); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; if (t is System.Security.SecurityException) { pictureBox.Image = SystemIcons.Information.ToBitmap(); } else { pictureBox.Image = SystemIcons.Error.ToBitmap(); } Controls.Add(pictureBox); message.SetBounds(scaledPictureWidth, scaledMessageTopPadding + (scaledMaxTextHeight - Math.Min(textSize.Height, scaledMaxTextHeight)) / 2, textSize.Width, textSize.Height); message.Text = messageText; Controls.Add(message); continueButton.Text = SR.ExDlgContinue; continueButton.FlatStyle = FlatStyle.Standard; continueButton.DialogResult = DialogResult.Cancel; quitButton.Text = SR.ExDlgQuit; quitButton.FlatStyle = FlatStyle.Standard; quitButton.DialogResult = DialogResult.Abort; helpButton.Text = SR.ExDlgHelp; helpButton.FlatStyle = FlatStyle.Standard; helpButton.DialogResult = DialogResult.Yes; detailsButton.Text = SR.ExDlgShowDetails; detailsButton.FlatStyle = FlatStyle.Standard; detailsButton.Click += new EventHandler(DetailsClick); Button b = null; int startIndex = 0; if (detailAnchor) { b = detailsButton; expandImage = DpiHelper.GetBitmapFromIcon(GetType(), DownBitmapName); collapseImage = DpiHelper.GetBitmapFromIcon(GetType(), UpBitmapName); if (DpiHelper.IsScalingRequirementMet) { ScaleBitmapLogicalToDevice(ref expandImage); ScaleBitmapLogicalToDevice(ref collapseImage); } b.SetBounds(scaledButtonDetailsLeftPadding, buttonTop, scaledButtonWidth, scaledButtonHeight); b.Image = expandImage; b.ImageAlign = ContentAlignment.MiddleLeft; Controls.Add(b); startIndex = 1; } int buttonLeft = (width - scaledButtonDetailsLeftPadding - ((buttons.Length - startIndex) * scaledButtonAlignmentWidth - scaledButtonAlignmentPadding)); for (int i = startIndex; i < buttons.Length; i++) { b = buttons[i]; b.SetBounds(buttonLeft, buttonTop, scaledButtonWidth, scaledButtonHeight); Controls.Add(b); buttonLeft += scaledButtonAlignmentWidth; } details.Text = detailsText; details.ScrollBars = ScrollBars.Both; details.Multiline = true; details.ReadOnly = true; details.WordWrap = false; details.TabStop = false; details.AcceptsReturn = false; details.SetBounds(scaledButtonDetailsLeftPadding, buttonTop + scaledButtonTopPadding, width - scaledDetailsWidthPadding, scaledDetailsHeight); details.Visible = detailsVisible; Controls.Add(details); if (DpiHelper.IsScalingRequirementMet) { DpiChanged += ThreadExceptionDialog_DpiChanged; } }
private void PerformLog(LogEntry logEntry) { RequestTelemetry requestTelemetry = null; if (logEntry.LogData.Any(ld => ld.Key == nameof(IRequestInformationProvider.DisplayUrl)) && HttpContextAccessor.HttpContext != null) { HttpContext httpContext = HttpContextAccessor.HttpContext; if (!httpContext.Items.ContainsKey(nameof(RequestTelemetry))) { throw new InvalidOperationException($"Register app insight logger using dependencyManager.{nameof(IDependencyManagerExtensions.RegisterApplicationInsights)}();"); } requestTelemetry = (RequestTelemetry)httpContext.Items[nameof(RequestTelemetry)]; IUserInformationProvider userInformationProvider = httpContext.RequestServices.GetRequiredService <IUserInformationProvider>(); if (userInformationProvider.IsAuthenticated()) { requestTelemetry.Context.User.AccountId = requestTelemetry.Context.User.AuthenticatedUserId = userInformationProvider.GetCurrentUserId(); } } List <KeyVal> keyValues = logEntry.LogData.Select(ld => { string k = ld.Key; if (k == nameof(IRequestInformationProvider.HttpMethod) || k == nameof(IRequestInformationProvider.DisplayUrl) || k == nameof(IRequestInformationProvider.UserAgent) || k == "UserId" || k == "ResponseStatusCode" || k == nameof(IRequestInformationProvider.ClientIp) || ld.Value == null) { return(null); // Already being logged by app insights! } string v = null; if (ld.Value is string valueAsStr) { v = valueAsStr; } if (k == "ClientLogs" || k == "OperationArgs") { v = Formatter.Serialize(ld.Value); } else { v = ld.Value.ToString(); } return(new KeyVal { Key = k, Value = v }); }) .Where(d => d != null) .ToList(); keyValues.Add(new KeyVal { Key = nameof(LogEntry.MemoryUsage), Value = logEntry.MemoryUsage.ToString() }); if (logEntry.AppServerDateTime.HasValue) { keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppServerDateTime), Value = logEntry.AppServerDateTime.ToString() }); } keyValues.Add(new KeyVal { Key = nameof(LogEntry.Severity), Value = logEntry.Severity }); keyValues.Add(new KeyVal { Key = nameof(LogEntry.Message), Value = logEntry.Message }); if (logEntry.Id.HasValue) { keyValues.Add(new KeyVal { Key = nameof(LogEntry.Id), Value = logEntry.Id.ToString() }); } if (logEntry.AppServerThreadId.HasValue) { keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppServerThreadId), Value = logEntry.AppServerThreadId.ToString() }); } if (requestTelemetry != null) { LogData userAgent = logEntry.LogData.FirstOrDefault(ld => ld.Key == nameof(IRequestInformationProvider.UserAgent)); if (userAgent != null) { requestTelemetry.Context.User.UserAgent = (string)userAgent.Value; } foreach (KeyVal keyVal in keyValues.OrderBy(kv => kv.Key)) { if (!requestTelemetry.Properties.ContainsKey(keyVal.Key)) { requestTelemetry.Properties.Add(keyVal.Key, keyVal.Value); } } } else { TelemetryClient telemetryClient = new TelemetryClient(); Dictionary <string, string> customData = new Dictionary <string, string>(); foreach (KeyVal keyVal in keyValues.OrderBy(kv => kv.Key)) { if (!customData.ContainsKey(keyVal.Key)) { customData.Add(keyVal.Key, keyVal.Value); } } Exception ex = null; try { customData.TryGetValue("ExceptionTypeAssemblyQualifiedName", out string exceptionTypeAssemblyQualifiedName); if (!string.IsNullOrEmpty(exceptionTypeAssemblyQualifiedName)) { ex = (Exception)Activator.CreateInstance(Type.GetType(exceptionTypeAssemblyQualifiedName) ?? throw new InvalidOperationException($"{exceptionTypeAssemblyQualifiedName} could not be found"), args: new object[] { logEntry.Message }); } } catch { } if (ex == null) { switch (logEntry.Severity) { case "Information": ex = new InformationException(logEntry.Message); break; case "Warning": ex = new WarningException(logEntry.Message); break; case "Error": ex = new ErrorException(logEntry.Message); break; case "Fatal": ex = new FatalException(logEntry.Message); break; default: ex = new Exception(logEntry.Message); break; } } telemetryClient.TrackException(ex, customData); } }
private void PerformLog(LogEntry logEntry) { TelemetryClient telemetryClient = null; IUserInformationProvider userInformationProvider = null; bool isPerRequestTelemetryClient = false; if (logEntry.LogData.Any(ld => ld.Key == nameof(IRequestInformationProvider.RequestUri))) { IOwinContext owinContext = OwinContext.Value; IDependencyResolver resolver = owinContext.GetDependencyResolver(); telemetryClient = resolver.Resolve <TelemetryClient>(); userInformationProvider = resolver.Resolve <IUserInformationProvider>(); isPerRequestTelemetryClient = true; } List <KeyVal> keyValues = logEntry.LogData.Select(ld => { string k = ld.Key; if (k == nameof(IRequestInformationProvider.HttpMethod) || k == nameof(IRequestInformationProvider.RequestUri) || k == nameof(IRequestInformationProvider.UserAgent) || k == "UserId" || k == "ResponseStatusCode" || k == nameof(IRequestInformationProvider.ClientIp) || ld.Value == null) { return(null); } string v = null; if (ld.Value is string valueAsStr) { v = valueAsStr; } if (k == "ClientLogs" || k == "OperationArgs") { v = Formatter.Serialize(ld.Value); } else { v = ld.Value.ToString(); } return(new KeyVal { Key = k, Value = v }); }) .Where(d => d != null) .ToList(); try { keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppEnvironmentName), Value = logEntry.AppEnvironmentName }); if (logEntry.AppServerProcessId.HasValue) { keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppServerProcessId), Value = logEntry.AppServerProcessId.ToString() }); } keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppServerAppDomainName), Value = logEntry.AppServerAppDomainName }); keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppServerOSVersion), Value = logEntry.AppServerOSVersion }); if (logEntry.AppServerDateTime.HasValue) { keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppServerDateTime), Value = logEntry.AppServerDateTime.ToString() }); } keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppServerName), Value = logEntry.AppServerName }); if (logEntry.AppWasInDebugMode.HasValue) { keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppWasInDebugMode), Value = logEntry.AppWasInDebugMode.ToString() }); } keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppServerUserAccountName), Value = logEntry.AppServerUserAccountName }); keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppVersion), Value = logEntry.AppVersion }); keyValues.Add(new KeyVal { Key = nameof(LogEntry.ApplicationName), Value = logEntry.ApplicationName }); keyValues.Add(new KeyVal { Key = nameof(LogEntry.Severity), Value = logEntry.Severity }); keyValues.Add(new KeyVal { Key = nameof(LogEntry.Message), Value = logEntry.Message }); if (logEntry.Id.HasValue) { keyValues.Add(new KeyVal { Key = nameof(LogEntry.Id), Value = logEntry.Id.ToString() }); } if (logEntry.AppServerThreadId.HasValue) { keyValues.Add(new KeyVal { Key = nameof(LogEntry.AppServerThreadId), Value = logEntry.AppServerThreadId.ToString() }); } if (isPerRequestTelemetryClient == true) { if (userInformationProvider.IsAuthenticated()) { telemetryClient.Context.User.AccountId = telemetryClient.Context.User.AuthenticatedUserId = userInformationProvider.GetCurrentUserId(); } LogData userAgent = logEntry.LogData.FirstOrDefault(ld => ld.Key == nameof(IRequestInformationProvider.UserAgent)); if (userAgent != null) { telemetryClient.Context.User.UserAgent = (string)userAgent.Value; } foreach (KeyVal keyVal in keyValues.OrderBy(kv => kv.Key)) { if (!telemetryClient.Context.Properties.ContainsKey(keyVal.Key)) { telemetryClient.Context.Properties.Add(keyVal.Key, keyVal.Value); } } } else { telemetryClient = new TelemetryClient(); Dictionary <string, string> customData = new Dictionary <string, string>(); foreach (KeyVal keyVal in keyValues.OrderBy(kv => kv.Key)) { if (!customData.ContainsKey(keyVal.Key)) { customData.Add(keyVal.Key, keyVal.Value); } } Exception ex = null; try { customData.TryGetValue("ExceptionTypeAssemblyQualifiedName", out string exceptionTypeAssemblyQualifiedName); if (!string.IsNullOrEmpty(exceptionTypeAssemblyQualifiedName)) { ex = (Exception)Activator.CreateInstance(Type.GetType(exceptionTypeAssemblyQualifiedName) ?? throw new InvalidOperationException($"{exceptionTypeAssemblyQualifiedName} could not be found"), args: new object[] { logEntry.Message }); } } catch { } if (ex == null) { switch (logEntry.Severity) { case "Information": ex = new InformationException(logEntry.Message); break; case "Warning": ex = new WarningException(logEntry.Message); break; case "Error": ex = new ErrorException(logEntry.Message); break; case "Fatal": ex = new FatalException(logEntry.Message); break; default: ex = new Exception(logEntry.Message); break; } } telemetryClient.TrackException(ex, customData); } } finally { telemetryClient.Flush(); } }
/// <include file='doc\ThreadExceptionDialog.uex' path='docs/doc[@for="ThreadExceptionDialog.ThreadExceptionDialog"]/*' /> /// <devdoc> /// <para> /// Initializes a new instance of the <see cref='System.Windows.Forms.ThreadExceptionDialog'/> class. /// /// </para> /// </devdoc> public ThreadExceptionDialog(Exception t) { string messageRes; string messageText; Button[] buttons; bool detailAnchor = false; WarningException w = t as WarningException; if (w != null) { messageRes = SR.ExDlgWarningText; messageText = w.Message; if (w.HelpUrl == null) { buttons = new Button[] { continueButton }; } else { buttons = new Button[] { continueButton, helpButton }; } } else { messageText = t.Message; detailAnchor = true; if (Application.AllowQuit) { if (t is SecurityException) { messageRes = "ExDlgSecurityErrorText"; } else { messageRes = "ExDlgErrorText"; } buttons = new Button[] { detailsButton, continueButton, quitButton }; } else { if (t is SecurityException) { messageRes = "ExDlgSecurityContinueErrorText"; } else { messageRes = "ExDlgContinueErrorText"; } buttons = new Button[] { detailsButton, continueButton }; } } if (messageText.Length == 0) { messageText = t.GetType().Name; } if (t is SecurityException) { messageText = SR.GetString(messageRes, t.GetType().Name, Trim(messageText)); } else { messageText = SR.GetString(messageRes, Trim(messageText)); } StringBuilder detailsTextBuilder = new StringBuilder(); string newline = "\r\n"; string separator = SR.GetString(SR.ExDlgMsgSeperator); string sectionseparator = SR.GetString(SR.ExDlgMsgSectionSeperator); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderNonSwitchable)); } else { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderSwitchable)); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgExceptionSection))); detailsTextBuilder.Append(t.ToString()); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgLoadedAssembliesSection))); new FileIOPermission(PermissionState.Unrestricted).Assert(); try { foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { AssemblyName name = asm.GetName(); string fileVer = SR.GetString(SR.NotAvailable); try { // bug 113573 -- if there's a path with an escaped value in it // like c:\temp\foo%2fbar, the AssemblyName call will unescape it to // c:\temp\foo\bar, which is wrong, and this will fail. It doesn't look like the // assembly name class handles this properly -- even the "CodeBase" property is un-escaped // so we can't circumvent this. // if (name.EscapedCodeBase != null && name.EscapedCodeBase.Length > 0) { Uri codeBase = new Uri(name.EscapedCodeBase); if (codeBase.Scheme == "file") { fileVer = FileVersionInfo.GetVersionInfo(NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion; } } } catch (System.IO.FileNotFoundException) { } detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgLoadedAssembliesEntry, name.Name, name.Version, fileVer, name.EscapedCodeBase)); detailsTextBuilder.Append(separator); } } finally { CodeAccessPermission.RevertAssert(); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgJITDebuggingSection))); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterNonSwitchable)); } else { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterSwitchable)); } detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); string detailsText = detailsTextBuilder.ToString(); Graphics g = message.CreateGraphicsInternal(); Size textSize = Size.Ceiling(g.MeasureString(messageText, Font, MAXWIDTH - 84)); textSize.Height += 4; g.Dispose(); if (textSize.Width < 180) { textSize.Width = 180; } if (textSize.Height > MAXHEIGHT) { textSize.Height = MAXHEIGHT; } int width = textSize.Width + 84; int buttonTop = Math.Max(textSize.Height, 40) + 26; // SECREVIEW : We must get a hold of the parent to get at it's text // : to make this dialog look like the parent. // IntSecurity.GetParent.Assert(); try { Form activeForm = Form.ActiveForm; if (activeForm == null || activeForm.Text.Length == 0) { Text = SR.GetString(SR.ExDlgCaption); } else { Text = SR.GetString(SR.ExDlgCaption2, activeForm.Text); } } finally { CodeAccessPermission.RevertAssert(); } AcceptButton = continueButton; CancelButton = continueButton; FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; MinimizeBox = false; StartPosition = FormStartPosition.CenterScreen; Icon = null; ClientSize = new Size(width, buttonTop + 31); TopMost = true; pictureBox.Location = new Point(0, 0); pictureBox.Size = new Size(64, 64); pictureBox.SizeMode = PictureBoxSizeMode.CenterImage; if (t is SecurityException) { pictureBox.Image = SystemIcons.Information.ToBitmap(); } else { pictureBox.Image = SystemIcons.Error.ToBitmap(); } Controls.Add(pictureBox); message.SetBounds(64, 8 + (40 - Math.Min(textSize.Height, 40)) / 2, textSize.Width, textSize.Height); message.Text = messageText; Controls.Add(message); continueButton.Text = SR.GetString(SR.ExDlgContinue); continueButton.FlatStyle = FlatStyle.Standard; continueButton.DialogResult = DialogResult.Cancel; quitButton.Text = SR.GetString(SR.ExDlgQuit); quitButton.FlatStyle = FlatStyle.Standard; quitButton.DialogResult = DialogResult.Abort; helpButton.Text = SR.GetString(SR.ExDlgHelp); helpButton.FlatStyle = FlatStyle.Standard; helpButton.DialogResult = DialogResult.Yes; detailsButton.Text = SR.GetString(SR.ExDlgShowDetails); detailsButton.FlatStyle = FlatStyle.Standard; detailsButton.Click += new EventHandler(DetailsClick); Button b = null; int startIndex = 0; if (detailAnchor) { b = detailsButton; expandImage = new Bitmap(this.GetType(), "down.bmp"); expandImage.MakeTransparent(); collapseImage = new Bitmap(this.GetType(), "up.bmp"); collapseImage.MakeTransparent(); b.SetBounds(8, buttonTop, 100, 23); b.Image = expandImage; b.ImageAlign = ContentAlignment.MiddleLeft; Controls.Add(b); startIndex = 1; } int buttonLeft = (width - 8 - ((buttons.Length - startIndex) * 105 - 5)); for (int i = startIndex; i < buttons.Length; i++) { b = buttons[i]; b.SetBounds(buttonLeft, buttonTop, 100, 23); Controls.Add(b); buttonLeft += 105; } details.Text = detailsText; details.ScrollBars = ScrollBars.Both; details.Multiline = true; details.ReadOnly = true; details.WordWrap = false; details.TabStop = false; details.AcceptsReturn = false; details.SetBounds(8, buttonTop + 31, width - 16, 154); Controls.Add(details); }
/// <include file='doc\ThreadExceptionDialog.uex' path='docs/doc[@for="ThreadExceptionDialog.ThreadExceptionDialog"]/*' /> /// <devdoc> /// <para> /// Initializes a new instance of the <see cref='System.Windows.Forms.ThreadExceptionDialog'/> class. /// /// </para> /// </devdoc> public ThreadExceptionDialog(Exception t) { if (DpiHelper.EnableThreadExceptionDialogHighDpiImprovements) { scaledMaxWidth = DpiHelper.LogicalToDeviceUnitsX(MAXWIDTH); scaledMaxHeight = DpiHelper.LogicalToDeviceUnitsY(MAXHEIGHT); scaledPaddingWidth = DpiHelper.LogicalToDeviceUnitsX(PADDINGWIDTH); scaledPaddingHeight = DpiHelper.LogicalToDeviceUnitsY(PADDINGHEIGHT); scaledMaxTextWidth = DpiHelper.LogicalToDeviceUnitsX(MAXTEXTWIDTH); scaledMaxTextHeight = DpiHelper.LogicalToDeviceUnitsY(MAXTEXTHEIGHT); scaledButtonTopPadding = DpiHelper.LogicalToDeviceUnitsY(BUTTONTOPPADDING); scaledButtonDetailsLeftPadding = DpiHelper.LogicalToDeviceUnitsX(BUTTONDETAILS_LEFTPADDING); scaledMessageTopPadding = DpiHelper.LogicalToDeviceUnitsY(MESSAGE_TOPPADDING); scaledHeightPadding = DpiHelper.LogicalToDeviceUnitsY(HEIGHTPADDING); scaledButtonWidth = DpiHelper.LogicalToDeviceUnitsX(BUTTONWIDTH); scaledButtonHeight = DpiHelper.LogicalToDeviceUnitsY(BUTTONHEIGHT); scaledButtonAlignmentWidth = DpiHelper.LogicalToDeviceUnitsX(BUTTONALIGNMENTWIDTH); scaledButtonAlignmentPadding = DpiHelper.LogicalToDeviceUnitsX(BUTTONALIGNMENTPADDING); scaledDetailsWidthPadding = DpiHelper.LogicalToDeviceUnitsX(DETAILSWIDTHPADDING); scaledDetailsHeight = DpiHelper.LogicalToDeviceUnitsY(DETAILSHEIGHT); scaledPictureWidth = DpiHelper.LogicalToDeviceUnitsX(PICTUREWIDTH); scaledPictureHeight = DpiHelper.LogicalToDeviceUnitsY(PICTUREHEIGHT); scaledExceptionMessageVerticalPadding = DpiHelper.LogicalToDeviceUnitsY(EXCEPTIONMESSAGEVERTICALPADDING); } string messageRes; string messageText; Button[] buttons; bool detailAnchor = false; WarningException w = t as WarningException; if (w != null) { messageRes = SR.ExDlgWarningText; messageText = w.Message; if (w.HelpUrl == null) { buttons = new Button[] { continueButton }; } else { buttons = new Button[] { continueButton, helpButton }; } } else { messageText = t.Message; detailAnchor = true; if (Application.AllowQuit) { if (t is SecurityException) { messageRes = "ExDlgSecurityErrorText"; } else { messageRes = "ExDlgErrorText"; } buttons = new Button[] { detailsButton, continueButton, quitButton }; } else { if (t is SecurityException) { messageRes = "ExDlgSecurityContinueErrorText"; } else { messageRes = "ExDlgContinueErrorText"; } buttons = new Button[] { detailsButton, continueButton }; } } if (messageText.Length == 0) { messageText = t.GetType().Name; } if (t is SecurityException) { messageText = SR.GetString(messageRes, t.GetType().Name, Trim(messageText)); } else { messageText = SR.GetString(messageRes, Trim(messageText)); } StringBuilder detailsTextBuilder = new StringBuilder(); string newline = "\r\n"; string separator = SR.GetString(SR.ExDlgMsgSeperator); string sectionseparator = SR.GetString(SR.ExDlgMsgSectionSeperator); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderNonSwitchable)); } else { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderSwitchable)); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgExceptionSection))); detailsTextBuilder.Append(t.ToString()); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgLoadedAssembliesSection))); new FileIOPermission(PermissionState.Unrestricted).Assert(); try { foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { AssemblyName name = asm.GetName(); string fileVer = SR.GetString(SR.NotAvailable); try { // bug 113573 -- if there's a path with an escaped value in it // like c:\temp\foo%2fbar, the AssemblyName call will unescape it to // c:\temp\foo\bar, which is wrong, and this will fail. It doesn't look like the // assembly name class handles this properly -- even the "CodeBase" property is un-escaped // so we can't circumvent this. // if (name.EscapedCodeBase != null && name.EscapedCodeBase.Length > 0) { Uri codeBase = new Uri(name.EscapedCodeBase); if (codeBase.Scheme == "file") { fileVer = FileVersionInfo.GetVersionInfo(NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion; } } } catch (System.IO.FileNotFoundException) { } detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgLoadedAssembliesEntry, name.Name, name.Version, fileVer, name.EscapedCodeBase)); detailsTextBuilder.Append(separator); } } finally { CodeAccessPermission.RevertAssert(); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgJITDebuggingSection))); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterNonSwitchable)); } else { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterSwitchable)); } detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); string detailsText = detailsTextBuilder.ToString(); Graphics g = message.CreateGraphicsInternal(); Size textSize = new Size(scaledMaxWidth - scaledPaddingWidth, int.MaxValue); if (DpiHelper.EnableThreadExceptionDialogHighDpiImprovements && (Label.UseCompatibleTextRenderingDefault == false)) { // we need to measure string using API that matches the rendering engine - TextRenderer.MeasureText for GDI textSize = Size.Ceiling(TextRenderer.MeasureText(messageText, Font, textSize, TextFormatFlags.WordBreak)); } else { // if HighDpi improvements are not enabled, or rendering mode is GDI+, use Graphics.MeasureString textSize = Size.Ceiling(g.MeasureString(messageText, Font, textSize.Width)); } textSize.Height += scaledExceptionMessageVerticalPadding; g.Dispose(); if (textSize.Width < scaledMaxTextWidth) { textSize.Width = scaledMaxTextWidth; } if (textSize.Height > scaledMaxHeight) { textSize.Height = scaledMaxHeight; } int width = textSize.Width + scaledPaddingWidth; int buttonTop = Math.Max(textSize.Height, scaledMaxTextHeight) + scaledPaddingHeight; // SECREVIEW : We must get a hold of the parent to get at it's text // : to make this dialog look like the parent. // IntSecurity.GetParent.Assert(); try { Form activeForm = Form.ActiveForm; if (activeForm == null || activeForm.Text.Length == 0) { Text = SR.GetString(SR.ExDlgCaption); } else { Text = SR.GetString(SR.ExDlgCaption2, activeForm.Text); } } finally { CodeAccessPermission.RevertAssert(); } AcceptButton = continueButton; CancelButton = continueButton; FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; MinimizeBox = false; StartPosition = FormStartPosition.CenterScreen; Icon = null; ClientSize = new Size(width, buttonTop + scaledButtonTopPadding); TopMost = true; pictureBox.Location = new Point(0, 0); pictureBox.Size = new Size(scaledPictureWidth, scaledPictureHeight); pictureBox.SizeMode = PictureBoxSizeMode.CenterImage; if (t is SecurityException) { pictureBox.Image = SystemIcons.Information.ToBitmap(); } else { pictureBox.Image = SystemIcons.Error.ToBitmap(); } Controls.Add(pictureBox); message.SetBounds(scaledPictureWidth, scaledMessageTopPadding + (scaledMaxTextHeight - Math.Min(textSize.Height, scaledMaxTextHeight)) / 2, textSize.Width, textSize.Height); message.Text = messageText; Controls.Add(message); continueButton.Text = SR.GetString(SR.ExDlgContinue); continueButton.FlatStyle = FlatStyle.Standard; continueButton.DialogResult = DialogResult.Cancel; quitButton.Text = SR.GetString(SR.ExDlgQuit); quitButton.FlatStyle = FlatStyle.Standard; quitButton.DialogResult = DialogResult.Abort; helpButton.Text = SR.GetString(SR.ExDlgHelp); helpButton.FlatStyle = FlatStyle.Standard; helpButton.DialogResult = DialogResult.Yes; detailsButton.Text = SR.GetString(SR.ExDlgShowDetails); detailsButton.FlatStyle = FlatStyle.Standard; detailsButton.Click += new EventHandler(DetailsClick); Button b = null; int startIndex = 0; if (detailAnchor) { b = detailsButton; expandImage = new Bitmap(this.GetType(), "down.bmp"); expandImage.MakeTransparent(); collapseImage = new Bitmap(this.GetType(), "up.bmp"); collapseImage.MakeTransparent(); if (DpiHelper.EnableThreadExceptionDialogHighDpiImprovements) { DpiHelper.ScaleBitmapLogicalToDevice(ref expandImage); DpiHelper.ScaleBitmapLogicalToDevice(ref collapseImage); } b.SetBounds(scaledButtonDetailsLeftPadding, buttonTop, scaledButtonWidth, scaledButtonHeight); b.Image = expandImage; b.ImageAlign = ContentAlignment.MiddleLeft; Controls.Add(b); startIndex = 1; } int buttonLeft = (width - scaledButtonDetailsLeftPadding - ((buttons.Length - startIndex) * scaledButtonAlignmentWidth - scaledButtonAlignmentPadding)); for (int i = startIndex; i < buttons.Length; i++) { b = buttons[i]; b.SetBounds(buttonLeft, buttonTop, scaledButtonWidth, scaledButtonHeight); Controls.Add(b); buttonLeft += scaledButtonAlignmentWidth; } details.Text = detailsText; details.ScrollBars = ScrollBars.Both; details.Multiline = true; details.ReadOnly = true; details.WordWrap = false; details.TabStop = false; details.AcceptsReturn = false; details.SetBounds(scaledButtonDetailsLeftPadding, buttonTop + scaledButtonTopPadding, width - scaledDetailsWidthPadding, scaledDetailsHeight); Controls.Add(details); }
public void WarningFaltaDatos(string Error) { WarningException ne = new WarningException(Error); MessageBox.Show(ne.Message, "Advertencia"); }
public WarningAnswer(WarningException wEx) : this(wEx.Code ?? WARN_CODE_DEFAULT, wEx.Message) { }
public ThreadExceptionDialog(Exception t) { string str; string message; Button[] buttonArray; this.pictureBox = new PictureBox(); this.message = new Label(); this.continueButton = new Button(); this.quitButton = new Button(); this.detailsButton = new Button(); this.helpButton = new Button(); this.details = new TextBox(); bool flag = false; WarningException exception = t as WarningException; if (exception != null) { str = "ExDlgWarningText"; message = exception.Message; if (exception.HelpUrl == null) { buttonArray = new Button[] { this.continueButton }; } else { buttonArray = new Button[] { this.continueButton, this.helpButton }; } } else { message = t.Message; flag = true; if (Application.AllowQuit) { if (t is SecurityException) { str = "ExDlgSecurityErrorText"; } else { str = "ExDlgErrorText"; } buttonArray = new Button[] { this.detailsButton, this.continueButton, this.quitButton }; } else { if (t is SecurityException) { str = "ExDlgSecurityContinueErrorText"; } else { str = "ExDlgContinueErrorText"; } buttonArray = new Button[] { this.detailsButton, this.continueButton }; } } if (message.Length == 0) { message = t.GetType().Name; } if (t is SecurityException) { message = System.Windows.Forms.SR.GetString(str, new object[] { t.GetType().Name, Trim(message) }); } else { message = System.Windows.Forms.SR.GetString(str, new object[] { Trim(message) }); } StringBuilder builder = new StringBuilder(); string str3 = "\r\n"; string str4 = System.Windows.Forms.SR.GetString("ExDlgMsgSeperator"); string format = System.Windows.Forms.SR.GetString("ExDlgMsgSectionSeperator"); if (Application.CustomThreadExceptionHandlerAttached) { builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgHeaderNonSwitchable")); } else { builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgHeaderSwitchable")); } builder.Append(string.Format(CultureInfo.CurrentCulture, format, new object[] { System.Windows.Forms.SR.GetString("ExDlgMsgExceptionSection") })); builder.Append(t.ToString()); builder.Append(str3); builder.Append(str3); builder.Append(string.Format(CultureInfo.CurrentCulture, format, new object[] { System.Windows.Forms.SR.GetString("ExDlgMsgLoadedAssembliesSection") })); new FileIOPermission(PermissionState.Unrestricted).Assert(); try { foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { AssemblyName name = assembly.GetName(); string fileVersion = System.Windows.Forms.SR.GetString("NotAvailable"); try { if ((name.EscapedCodeBase != null) && (name.EscapedCodeBase.Length > 0)) { Uri uri = new Uri(name.EscapedCodeBase); if (uri.Scheme == "file") { fileVersion = FileVersionInfo.GetVersionInfo(System.Windows.Forms.NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion; } } } catch (FileNotFoundException) { } builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgLoadedAssembliesEntry", new object[] { name.Name, name.Version, fileVersion, name.EscapedCodeBase })); builder.Append(str4); } } finally { CodeAccessPermission.RevertAssert(); } builder.Append(string.Format(CultureInfo.CurrentCulture, format, new object[] { System.Windows.Forms.SR.GetString("ExDlgMsgJITDebuggingSection") })); if (Application.CustomThreadExceptionHandlerAttached) { builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgFooterNonSwitchable")); } else { builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgFooterSwitchable")); } builder.Append(str3); builder.Append(str3); string str7 = builder.ToString(); Graphics graphics = this.message.CreateGraphicsInternal(); Size size = Size.Ceiling(graphics.MeasureString(message, this.Font, 0x164)); size.Height += 4; graphics.Dispose(); if (size.Width < 180) { size.Width = 180; } if (size.Height > 0x145) { size.Height = 0x145; } int width = size.Width + 0x54; int y = Math.Max(size.Height, 40) + 0x1a; System.Windows.Forms.IntSecurity.GetParent.Assert(); try { Form activeForm = Form.ActiveForm; if ((activeForm == null) || (activeForm.Text.Length == 0)) { this.Text = System.Windows.Forms.SR.GetString("ExDlgCaption"); } else { this.Text = System.Windows.Forms.SR.GetString("ExDlgCaption2", new object[] { activeForm.Text }); } } finally { CodeAccessPermission.RevertAssert(); } base.AcceptButton = this.continueButton; base.CancelButton = this.continueButton; base.FormBorderStyle = FormBorderStyle.FixedDialog; base.MaximizeBox = false; base.MinimizeBox = false; base.StartPosition = FormStartPosition.CenterScreen; base.Icon = null; base.ClientSize = new Size(width, y + 0x1f); base.TopMost = true; this.pictureBox.Location = new Point(0, 0); this.pictureBox.Size = new Size(0x40, 0x40); this.pictureBox.SizeMode = PictureBoxSizeMode.CenterImage; if (t is SecurityException) { this.pictureBox.Image = SystemIcons.Information.ToBitmap(); } else { this.pictureBox.Image = SystemIcons.Error.ToBitmap(); } base.Controls.Add(this.pictureBox); this.message.SetBounds(0x40, 8 + ((40 - Math.Min(size.Height, 40)) / 2), size.Width, size.Height); this.message.Text = message; base.Controls.Add(this.message); this.continueButton.Text = System.Windows.Forms.SR.GetString("ExDlgContinue"); this.continueButton.FlatStyle = FlatStyle.Standard; this.continueButton.DialogResult = DialogResult.Cancel; this.quitButton.Text = System.Windows.Forms.SR.GetString("ExDlgQuit"); this.quitButton.FlatStyle = FlatStyle.Standard; this.quitButton.DialogResult = DialogResult.Abort; this.helpButton.Text = System.Windows.Forms.SR.GetString("ExDlgHelp"); this.helpButton.FlatStyle = FlatStyle.Standard; this.helpButton.DialogResult = DialogResult.Yes; this.detailsButton.Text = System.Windows.Forms.SR.GetString("ExDlgShowDetails"); this.detailsButton.FlatStyle = FlatStyle.Standard; this.detailsButton.Click += new EventHandler(this.DetailsClick); Button detailsButton = null; int num3 = 0; if (flag) { detailsButton = this.detailsButton; this.expandImage = new Bitmap(base.GetType(), "down.bmp"); this.expandImage.MakeTransparent(); this.collapseImage = new Bitmap(base.GetType(), "up.bmp"); this.collapseImage.MakeTransparent(); detailsButton.SetBounds(8, y, 100, 0x17); detailsButton.Image = this.expandImage; detailsButton.ImageAlign = ContentAlignment.MiddleLeft; base.Controls.Add(detailsButton); num3 = 1; } int x = (width - 8) - (((buttonArray.Length - num3) * 0x69) - 5); for (int i = num3; i < buttonArray.Length; i++) { detailsButton = buttonArray[i]; detailsButton.SetBounds(x, y, 100, 0x17); base.Controls.Add(detailsButton); x += 0x69; } this.details.Text = str7; this.details.ScrollBars = ScrollBars.Both; this.details.Multiline = true; this.details.ReadOnly = true; this.details.WordWrap = false; this.details.TabStop = false; this.details.AcceptsReturn = false; this.details.SetBounds(8, y + 0x1f, width - 0x10, 0x9a); base.Controls.Add(this.details); }