Small bits of refactoring.
3 Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 The contents of this file are subject to the Mozilla Public License Version
6 1.1 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 for the specific language governing rights and limitations under the License.
15 The Original Code is the Open Hardware Monitor code.
17 The Initial Developer of the Original Code is
18 Michael Möller <m.moeller@gmx.ch>.
19 Portions created by the Initial Developer are Copyright (C) 2009-2010
20 the Initial Developer. All Rights Reserved.
24 Alternatively, the contents of this file may be used under the terms of
25 either the GNU General Public License Version 2 or later (the "GPL"), or
26 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 in which case the provisions of the GPL or the LGPL are applicable instead
28 of those above. If you wish to allow use of your version of this file only
29 under the terms of either the GPL or the LGPL, and not to allow others to
30 use your version of this file under the terms of the MPL, indicate your
31 decision by deleting the provisions above and replace them with the notice
32 and other provisions required by the GPL or the LGPL. If you do not delete
33 the provisions above, a recipient may use your version of this file under
34 the terms of any one of the MPL, the GPL or the LGPL.
42 using System.Windows.Forms;
44 namespace OpenHardwareMonitor.GUI {
45 public partial class CrashForm : Form {
47 private Exception exception;
50 InitializeComponent();
53 public Exception Exception {
54 get { return exception; }
57 StringBuilder s = new StringBuilder();
58 Version version = typeof(CrashForm).Assembly.GetName().Version;
59 s.Append("Version: "); s.AppendLine(version.ToString());
61 s.AppendLine(exception.ToString());
63 if (exception.InnerException != null) {
64 s.AppendLine(exception.InnerException.ToString());
67 s.Append("Common Language Runtime: ");
68 s.AppendLine(Environment.Version.ToString());
69 s.Append("Operating System: ");
70 s.AppendLine(Environment.OSVersion.ToString());
71 s.Append("Process Type: ");
72 s.AppendLine(IntPtr.Size == 4 ? "32-Bit" : "64-Bit");
73 reportTextBox.Text = s.ToString();
77 private void sendButton_Click(object sender, EventArgs e) {
79 Version version = typeof(CrashForm).Assembly.GetName().Version;
80 WebRequest request = WebRequest.Create(
81 "http://openhardwaremonitor.org/report.php");
82 request.Method = "POST";
83 request.Timeout = 5000;
84 request.ContentType = "application/x-www-form-urlencoded";
88 "version=" + Uri.EscapeDataString(version.ToString()) + "&" +
89 "report=" + Uri.EscapeDataString(reportTextBox.Text) + "&" +
90 "comment=" + Uri.EscapeDataString(commentTextBox.Text) + "&" +
91 "email=" + Uri.EscapeDataString(emailTextBox.Text);
92 byte[] byteArray = Encoding.UTF8.GetBytes(report);
93 request.ContentLength = byteArray.Length;
96 Stream dataStream = request.GetRequestStream();
97 dataStream.Write(byteArray, 0, byteArray.Length);
100 WebResponse response = request.GetResponse();
101 dataStream = response.GetResponseStream();
102 StreamReader reader = new StreamReader(dataStream);
103 string responseFromServer = reader.ReadToEnd();
109 } catch (WebException) {
110 MessageBox.Show("Sending the crash report failed.", "Error",
111 MessageBoxButtons.OK, MessageBoxIcon.Error);