From 7c3a2d4dbee223e8cfba4980a47e42784e45bc29 Mon Sep 17 00:00:00 2001 From: Jimmy Quach Date: Sun, 17 Mar 2024 20:01:35 -0700 Subject: [PATCH] fix: NullReferenceException during some debug sessions ...and not include a bunch of other work-in-progress changes this time --- Classes/Utils/Helpers.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Classes/Utils/Helpers.cs b/Classes/Utils/Helpers.cs index e0242d8c..cc79d3be 100644 --- a/Classes/Utils/Helpers.cs +++ b/Classes/Utils/Helpers.cs @@ -38,10 +38,15 @@ public static string GetSolutionPath() { while (directory != null && !directory.GetFiles("*.sln").Any()) { directory = directory.Parent; } - if (directory == null) { + if (directory != null) { + return directory.FullName; + } + try { return Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName; } - return directory.FullName; + catch (NullReferenceException) { + return Directory.GetCurrentDirectory(); + } } #endif public static void PlaySound(string fileName) {