@@ -202,13 +202,7 @@ private static void HandleException(Exception exception)
202
202
if ( exception == null )
203
203
return ;
204
204
205
- SentryId eventId = default ;
206
- SentrySdk . WithScope ( scope =>
207
- {
208
- scope . AddAttachment ( AppConfigs . Configuration . FileLocation ) ;
209
- eventId = SentrySdk . CaptureException ( exception ) ;
210
- }
211
- ) ;
205
+ var eventId = SentrySdk . CaptureException ( exception , scope => { scope . AddAttachment ( AppConfigs . Configuration . FileLocation ) ; } ) ;
212
206
213
207
var exceptionMessage = exception . Message ;
214
208
if ( exception . InnerException != null )
@@ -224,10 +218,25 @@ private static void HandleException(Exception exception)
224
218
Would you like to share more information with the developers?" ;
225
219
var result = DialogResult . None ;
226
220
var syncContext = _synchronizationContext ?? SynchronizationContext . Current ;
227
- syncContext . Send ( state =>
221
+ syncContext ? . Send ( state =>
228
222
{
229
- result = MessageBox . Show ( message , $@ "{ Application . ProductName } crashed...", MessageBoxButtons . YesNo ,
230
- MessageBoxIcon . Error ) ;
223
+ try
224
+ {
225
+ try
226
+ {
227
+ result = MessageBox . Show ( message , $@ "{ Application . ProductName } crashed...", MessageBoxButtons . YesNo ,
228
+ MessageBoxIcon . Error ) ;
229
+ }
230
+ catch ( InvalidOperationException )
231
+ {
232
+ result = MessageBox . Show ( message , $@ "{ Application . ProductName } crashed...", MessageBoxButtons . YesNo ,
233
+ MessageBoxIcon . Error , MessageBoxDefaultButton . Button1 , MessageBoxOptions . ServiceNotification ) ;
234
+ }
235
+ }
236
+ catch ( Exception )
237
+ {
238
+ Log . Warning ( "Couldn't warn the user about the crash" ) ;
239
+ }
231
240
} , null ) ;
232
241
233
242
0 commit comments