Skip to content

Commit 8debe93

Browse files
committed
Added diagnostics to analyze why Excel doesn't start on certain PCs.
1 parent a5b1f81 commit 8debe93

5 files changed

Lines changed: 82 additions & 57 deletions

File tree

AnalyzeInExcel/App.xaml.cs

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -59,67 +59,71 @@ protected override void OnStartup(StartupEventArgs e)
5959
bool disableTelemetry = (AppOptions.Telemetry == false);
6060
TelemetryHelper th = new TelemetryHelper(disableTelemetry);
6161

62-
string serverName = ((App)Application.Current).AppOptions?.Server;
63-
string databaseName = ((App)Application.Current).AppOptions?.Database;
64-
string cubeName = ModelHelper.GetModelName(serverName, databaseName);
65-
if (serverName != null && databaseName != null)
62+
try
6663
{
67-
try
64+
string serverName = ((App)Application.Current).AppOptions?.Server;
65+
string databaseName = ((App)Application.Current).AppOptions?.Database;
66+
string cubeName = ModelHelper.GetModelName(serverName, databaseName, th);
67+
if (serverName != null && databaseName != null)
6868
{
69-
if (string.IsNullOrEmpty(cubeName))
69+
try
7070
{
71-
ShowMessage("Power BI has an empty model or it is connected to an unkonwn external dataset. You cannot connect Excel.");
72-
th.TrackEvent("Model not available");
73-
}
74-
else if (ExcelHelper.IsExcelAvailable())
75-
{
76-
// TODO: Manage options requested
77-
if (OptionsRequested)
71+
if (string.IsNullOrEmpty(cubeName))
7872
{
79-
// TODO request action / configuration to users
73+
ShowMessage("Power BI has an empty model or it is connected to an unkonwn external dataset. You cannot connect Excel.");
74+
th.TrackEvent("Model not available");
8075
}
81-
82-
// Create ODC file
83-
OdcHelper.CreateOdcFile(serverName, databaseName, cubeName);
84-
var fileName = OdcHelper.OdcFilePath();
85-
86-
// Open ODC file
87-
var p = new Process
76+
else if (ExcelHelper.IsExcelAvailable())
8877
{
89-
StartInfo = new ProcessStartInfo(fileName)
78+
// TODO: Manage options requested
79+
if (OptionsRequested)
9080
{
91-
UseShellExecute = true
81+
// TODO request action / configuration to users
9282
}
93-
};
94-
th.TrackEvent("Run Excel");
95-
p.Start();
83+
84+
RunExcelProcess(serverName, databaseName, cubeName);
85+
th.TrackEvent("Run Excel");
86+
}
87+
else
88+
{
89+
ShowMessage("Excel is not available. Please check whether Excel is correctly installed.");
90+
th.TrackEvent("Excel not available");
91+
}
92+
th.Flush();
93+
94+
// Check updates synchronously when Excel starts, no wait for Excel
95+
CheckUpdates(true);
96+
this.Shutdown(0);
9697
}
97-
else
98+
catch (Exception ex)
9899
{
99-
ShowMessage("Excel is not available. Please check whether Excel is correctly installed.");
100-
th.TrackEvent("Excel not available");
100+
th.TrackException(ex);
101+
th.Flush();
102+
ShowMessage("Error launching Excel: " + ex.Message);
101103
}
102-
th.Flush();
103-
// Check updates synchronously when Excel starts, no wait for Excel
104-
CheckUpdates(true);
105-
this.Shutdown(0);
106104
}
107-
catch (Exception ex)
105+
else
108106
{
109-
th.TrackException(ex);
107+
th.TrackEvent("Configuration incomplete");
110108
th.Flush();
111-
ShowMessage("Error launching Excel: " + ex.Message);
112109
}
110+
111+
// Check updates asynchronously when there is an error, while displaying the diagnostic message
112+
CheckUpdates(false);
113+
114+
OpenDiagnosticWindow(serverName, databaseName);
113115
}
114-
else
116+
catch (Exception ex)
115117
{
116-
th.TrackEvent("Configuration incomplete");
118+
// Send any exception to Telemetry
119+
th.TrackException(ex);
117120
th.Flush();
121+
throw;
118122
}
119123

120-
// Check updates asynchronously when there is an error, while displaying the diagnostic message
121-
CheckUpdates(false);
122-
124+
}
125+
private void OpenDiagnosticWindow(string serverName, string databaseName)
126+
{
123127
//// start application window
124128
MainWindow mw = new MainWindow();
125129
mw.diagnosticInfo.Content = $@"Current configuration
@@ -133,5 +137,22 @@ Check that the file
133137
";
134138
mw.Show();
135139
}
140+
141+
private void RunExcelProcess(string serverName, string databaseName, string cubeName)
142+
{
143+
// Create ODC file
144+
OdcHelper.CreateOdcFile(serverName, databaseName, cubeName);
145+
var fileName = OdcHelper.OdcFilePath();
146+
147+
// Open ODC file
148+
var p = new Process
149+
{
150+
StartInfo = new ProcessStartInfo(fileName)
151+
{
152+
UseShellExecute = true
153+
}
154+
};
155+
p.Start();
156+
}
136157
}
137158
}

AnalyzeInExcel/ModelHelper.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ public static string GetOleDbConnectionString( string serverName, string databas
7777
/// <param name="serverName">Server name</param>
7878
/// <param name="databaseName">Database name</param>
7979
/// <returns>true it the connection has a data model</returns>
80-
public static string GetModelName(string serverName, string databaseName)
80+
public static string GetModelName(string serverName, string databaseName, TelemetryHelper th)
8181
{
8282
string result = null;
8383
string connectionString = GetOleDbConnectionString(serverName, databaseName);
84-
using (OleDbConnection connection = new OleDbConnection(connectionString))
84+
try
8585
{
86-
try
86+
using (OleDbConnection connection = new OleDbConnection(connectionString))
8787
{
8888
using (OleDbCommand command = new OleDbCommand("select CUBE_NAME from $SYSTEM.MDSCHEMA_CUBES", connection))
8989
{
@@ -98,10 +98,14 @@ public static string GetModelName(string serverName, string databaseName)
9898
}
9999
}
100100
}
101-
catch (System.Data.Common.DbException)
102-
{
103-
// Ignore DB Exception and return a null model name
104-
}
101+
}
102+
catch (System.Data.Common.DbException ex)
103+
{
104+
// Ignore DbException and return a null model name
105+
106+
// Send exception to Telemetry for further investigation
107+
th.TrackException(ex);
108+
th.Flush();
105109
}
106110
return result;
107111
}

AnalyzeInExcel/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.0.2.0")]
55-
[assembly: AssemblyFileVersion("1.0.2.0")]
54+
[assembly: AssemblyVersion("1.0.3.0")]
55+
[assembly: AssemblyFileVersion("1.0.3.0")]

ExternalToolsInstaller/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.2.0")]
36-
[assembly: AssemblyFileVersion("1.0.2.0")]
35+
[assembly: AssemblyVersion("1.0.3.0")]
36+
[assembly: AssemblyFileVersion("1.0.3.0")]

SetupAnalyzeInExcel/SetupAnalyzeInExcel.vdproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,15 +3420,15 @@
34203420
{
34213421
"Name" = "8:Microsoft Visual Studio"
34223422
"ProductName" = "8:Analyze in Excel for Power BI Desktop"
3423-
"ProductCode" = "8:{F915B871-1BEE-41BD-A7FE-4A11893A1C19}"
3424-
"PackageCode" = "8:{4B1C7F17-58B4-44FC-A1ED-51BC6D080AD0}"
3423+
"ProductCode" = "8:{46AF827B-0E49-4907-92FC-C60096C08105}"
3424+
"PackageCode" = "8:{588D46CE-2E9A-45E4-BDBA-03AA560416EF}"
34253425
"UpgradeCode" = "8:{FC2F9C00-CAD5-455E-BD9D-B1C607F4ABDA}"
34263426
"AspNetVersion" = "8:4.0.30319.0"
34273427
"RestartWWWService" = "11:FALSE"
34283428
"RemovePreviousVersions" = "11:TRUE"
34293429
"DetectNewerInstalledVersion" = "11:TRUE"
34303430
"InstallAllUsers" = "11:TRUE"
3431-
"ProductVersion" = "8:1.0.2"
3431+
"ProductVersion" = "8:1.0.3"
34323432
"Manufacturer" = "8:Sqlbi"
34333433
"ARPHELPTELEPHONE" = "8:"
34343434
"ARPHELPLINK" = "8:"
@@ -4116,7 +4116,7 @@
41164116
{
41174117
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_B8059F38185844FF9E7100633B552E00"
41184118
{
4119-
"SourcePath" = "8:..\\AnalyzeInExcel\\obj\\Release\\AnalyzeInExcel.exe"
4119+
"SourcePath" = "8:..\\AnalyzeInExcel\\obj\\Debug\\AnalyzeInExcel.exe"
41204120
"TargetName" = "8:"
41214121
"Tag" = "8:"
41224122
"Folder" = "8:_3C819D033B8E4ED29DA3C4B4E2E7B98C"
@@ -4144,7 +4144,7 @@
41444144
}
41454145
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_BE740B1BEB9D410F82DDE5AF811E1E7C"
41464146
{
4147-
"SourcePath" = "8:..\\ExternalToolsInstaller\\obj\\Release\\ExternalToolsInstaller.dll"
4147+
"SourcePath" = "8:..\\ExternalToolsInstaller\\obj\\Debug\\ExternalToolsInstaller.dll"
41484148
"TargetName" = "8:"
41494149
"Tag" = "8:"
41504150
"Folder" = "8:_3C819D033B8E4ED29DA3C4B4E2E7B98C"

0 commit comments

Comments
 (0)