bramdejager / spcb

The SharePoint Client Browser (SPCB) uses the CSOM to connect to a remote SharePoint site collection and shows the site structure with related properties and values.
GNU General Public License v2.0
174 stars 48 forks source link

Null reference exception on startup #34

Closed bramdejager closed 6 years ago

bramdejager commented 6 years ago

When launching application I can see message "Loading recent tenants and sites..." then null reference exception is thrown.

here is the log file: Time;Machine;Process;Version;Category;EventId;Level;Correlation;Message 23-08-2015 11:04:59.415;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3;Error while retrieving default browser setting. 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3;System.NullReferenceException: Object reference not set to an instance of an object. 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Utils.BrowserUtil.GetBrowsers() 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Utils.BrowserUtil.GetSystemDefaultBrowser() 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3;Object reference not set to an instance of an object. 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3;System.NullReferenceException: Object reference not set to an instance of an object. 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Utils.BrowserUtil.GetBrowsers() 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Utils.BrowserUtil.GetBrowser(String name) 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Configuration..ctor() 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Configuration.get_Current() 23-08-2015 11:04:59.431;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Utils.LogUtil.TruncateLogFiles() 23-08-2015 11:04:59.447;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3;Error while retrieving default browser setting. 23-08-2015 11:04:59.447;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3;System.NullReferenceException: Object reference not set to an instance of an object. 23-08-2015 11:04:59.447;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Utils.BrowserUtil.GetBrowsers() 23-08-2015 11:04:59.447;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Utils.BrowserUtil.GetSystemDefaultBrowser() 23-08-2015 11:05:13.362;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3;Object reference not set to an instance of an object. 23-08-2015 11:05:13.362;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3;System.NullReferenceException: Object reference not set to an instance of an object. 23-08-2015 11:05:13.362;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Utils.BrowserUtil.GetBrowsers() 23-08-2015 11:05:13.362;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Utils.BrowserUtil.GetBrowser(String name) 23-08-2015 11:05:13.362;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Configuration..ctor() 23-08-2015 11:05:13.362;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Configuration.get_Current() 23-08-2015 11:05:13.362;SP2013DEV;SPCB.exe;1.7.0.0;General;0;Exception;73cdc001-4954-4e67-bead-b2aeae5b02d3; at SPBrowser.Program.Main(String[] args)

I looked into the code for method GetBrowsers, trying to run it on my environment and find that it fails under line RegistryKey browserKeyPath = browserKey.OpenSubKey(@"shell\open\command"); var Path = (string)browserKeyPath.GetValue(null).ToString();

browserKeyPath is null, that's why null reference is thrown. I looked into my regedit and find that I have mystic Tourch browser installed without shell\open\command subtree. (see attach). After deleting all works fine. I think it will be good if you can include additional check in your code to prevent such situations.

Thanks!

Attachments

2015-08-23_1154.png

This work item was migrated from CodePlex

CodePlex work item ID: '63930' Assigned to: 'BdeJager' Vote count: '1'

bramdejager commented 6 years ago

[BdeJager@23-8-2015] Thanks for the research! I added exception handling and will silently drop the browsers, who cause an exception. Otherwise I have to support all exotic registry entries related to browsers. Browsers like Internet Explorer, Google Chrome and Firefox all have the registry entry 'shell\open\command'.

Sorry to not support Torch as an alternative browser in SPCB. When it's your default browser, it should work fine!

The fix is included in the next release.

bramdejager commented 6 years ago

[UnknownUser@23-8-2015] Associated with changeset 75928: Fixed loading browsers who do not support default Registry locations, like Torch browser.

bramdejager commented 6 years ago

[UnknownUser@23-8-2015]