25
25
26
26
using System ;
27
27
using System . ComponentModel . Design ;
28
- using System . Diagnostics ;
29
28
using System . Runtime . InteropServices ;
30
29
using System . Security . Principal ;
31
30
using System . Windows ;
32
- using BridgeVs . Locations ;
33
31
using BridgeVs . VsPackage . Helper ;
34
32
using BridgeVs . VsPackage . Helper . Configuration ;
35
33
using BridgeVs . VsPackage . Helper . Installer ;
36
34
using BridgeVs . VsPackage . Helper . Settings ;
37
35
using EnvDTE ;
38
36
using Microsoft . VisualStudio ;
39
- using Microsoft . VisualStudio . Settings ;
40
37
using Microsoft . VisualStudio . Shell ;
41
38
using Microsoft . VisualStudio . Shell . Interop ;
42
- using Microsoft . VisualStudio . Shell . Settings ;
43
39
44
40
namespace BridgeVs . VsPackage . Package
45
41
{
@@ -72,6 +68,12 @@ public sealed class BridgeVsPackage : Microsoft.VisualStudio.Shell.Package
72
68
//if this is not null means vs has to restart
73
69
private Welcome _welcomePage ;
74
70
private bool ? _installationResult ;
71
+ private class Error
72
+ {
73
+ public string Body ;
74
+ public string Title ;
75
+ }
76
+ private Error _error ;
75
77
public static bool IsElevated => new WindowsPrincipal ( WindowsIdentity . GetCurrent ( ) ) . IsInRole ( WindowsBuiltInRole . Administrator ) ;
76
78
private PackageSettings _packageSettings ;
77
79
#region Package Members
@@ -120,7 +122,7 @@ protected override void Initialize()
120
122
mcs . AddCommand ( menuItemSendFeedback ) ;
121
123
//Initialize Object Exporter settings
122
124
_packageSettings = ( PackageSettings ) GetDialogPage ( typeof ( PackageSettings ) ) ;
123
-
125
+
124
126
try
125
127
{ //if first time user
126
128
if ( isLinqBridgeVsConfigured )
@@ -144,28 +146,46 @@ protected override void Initialize()
144
146
}
145
147
catch ( Exception e )
146
148
{
147
- Trace . Write ( "LINQBridgeVs: Initialize Error... " + e . Message ) ;
148
- Trace . Write ( e . StackTrace ) ;
149
- MessageBox . Show ( $ "LINQBridgeVs: Configuration unsuccessful. Please open a new issue on GitHub. Error: { e . Message } ") ;
149
+ _error = new Error ( ) ;
150
+ _error . Body = $ "{ e . Message } %0A { e . StackTrace } ";
151
+ _error . Title = "Error during installation. 1.4.6" ;
152
+ Exception innerException = e . InnerException ;
153
+ while ( innerException != null )
154
+ {
155
+ _error . Body += $ "%0A { innerException . Message } { innerException . StackTrace } ";
156
+ innerException = innerException . InnerException ;
157
+ }
158
+ _error . Body = _error . Body . Replace ( Environment . NewLine , "%0A" ) ;
150
159
}
151
160
}
152
161
153
162
private void _dteEvents_OnStartupComplete ( )
154
163
{
155
164
_welcomePage ? . Show ( ) ;
165
+
166
+ if ( _error != null )
167
+ {
168
+ var boxresult = MessageBox . Show ( $ "Configuration unsuccessful. Do you want to open an issue on GitHub?", "LINQBridgeVs: Error during the configuration" , MessageBoxButton . YesNo ) ;
169
+ if ( boxresult == MessageBoxResult . Yes )
170
+ {
171
+ System . Diagnostics . Process . Start ( $ "https://github.com/codingadventures/LINQBridgeVs/issues/new?title={ _error . Title } &body={ _error . Body } ") ;
172
+ }
173
+ _error = null ;
174
+ }
175
+
156
176
if ( _installationResult == null )
157
177
return ;
158
178
159
- var messageResult = MessageBox . Show ( "Do you want to send anonymous error reports to LINQBridgeVs?" , "LINQBridgeVs" , MessageBoxButton . YesNo , MessageBoxImage . Question , MessageBoxResult . No ) ;
179
+ var messageResult = MessageBox . Show ( "Do you want to send anonymous error reports to LINQBridgeVs?" , "LINQBridgeVs: Error Tracking " , MessageBoxButton . YesNo , MessageBoxImage . Question , MessageBoxResult . No ) ;
160
180
161
181
_packageSettings . ErrorTrackingEnabled = messageResult == MessageBoxResult . Yes ;
162
182
_packageSettings . SaveSettingsToStorage ( ) ;
163
183
164
184
MessageBox . Show ( _installationResult . Value
165
185
? "LINQBridgeVs has been successfully configured."
166
- : "LINQBridgeVs wasn't successfully configured. Please check the logs in the output folder " ) ;
186
+ : "LINQBridgeVs wasn't successfully configured." ) ;
167
187
}
168
-
188
+
169
189
#endregion
170
190
}
171
191
}
0 commit comments