sql-bi / AnalyzeInExcel

Analyze in Excel for Power BI Desktop
MIT License
82 stars 16 forks source link

Automatic attachment of the debugger at launch when using the Debug version #8

Closed SergioMurru closed 4 years ago

SergioMurru commented 4 years ago

The purpose of this change is to ease debugging when launching the application from Power BI

I added the

if DEBUG

        System.Diagnostics.Debugger.Launch();

endif

code at the beginning of the OnStartup() method.

DEBUG is automatically defined in the project properties only when compiling for the Debug version and therefore the Release version is not affected by this change.

When using the Debug version, after clicking on the Analyze in Excel icon in Power BI, the Debugger.Launch() method shows a window allowing to attach the current process to the debugger into the currently running instance of Visual Studio. Choosing this options will stop the application on the System.Diagnostic.Debugger.Launch() line inside Visual Studio debugger. Then the usual debugger commands can be used.

The window shown by Debugger.Launch() can be dismissed by choosing the Cancel button, therefore skipping the debugger attachment and continuing with the normal execution.

If there isn't a running instance of Visual Studio, a new one can be automatically run.