diff --git a/ConnectorCore/DllConflictManagement/DllConflictManager.cs b/ConnectorCore/DllConflictManagement/DllConflictManager.cs index 26f34f13c2..3921b8ee36 100644 --- a/ConnectorCore/DllConflictManagement/DllConflictManager.cs +++ b/ConnectorCore/DllConflictManagement/DllConflictManager.cs @@ -101,11 +101,29 @@ HashSet visitedAssemblies } } - private bool ShouldSkipCheckingConflictBecauseOfAssemblyLocation(Assembly loadedAssembly) + private static bool PathIsValid(string path) { + if (path.Any(x => Path.GetInvalidPathChars().Contains(x))) + { + return false; + } + return true; + } + + private bool ShouldSkipCheckingConflictBecauseOfAssemblyLocation(Assembly? loadedAssembly) + { + if (string.IsNullOrWhiteSpace(loadedAssembly?.Location)) + { + return false; + } + string location = loadedAssembly!.Location; + if (!PathIsValid(location)) + { + return false; + } foreach (var exactPath in _exactAssemblyPathsToIgnore) { - if (Path.GetDirectoryName(loadedAssembly.Location) == exactPath) + if (Path.GetDirectoryName(location) == exactPath) { return true; } @@ -113,7 +131,7 @@ private bool ShouldSkipCheckingConflictBecauseOfAssemblyLocation(Assembly loaded foreach (var pathFragment in _assemblyPathFragmentsToIgnore) { - if (loadedAssembly.Location.Contains(pathFragment)) + if (location.Contains(pathFragment)) { return true; }