-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AndroidSdkWindows] Guard against exception checking registry. #79
Conversation
In-progress commit message:
|
Two questions:
|
It feels like this was super-unimportant. The registry is just one of many places we check, and if we can't find it there we move on to the others. However the one thing it shouldn't do is crash for any reason, because it completely blocks a user from being able to do anything, even if other detection methods would have succeeded. |
Draft release notes Here is the Xamarin.Android release note I plan to include for this pull request:
To suggest any edits to this, feel free to reply in this PR. Thanks! |
Fixes: https://developercommunity.visualstudio.com/content/problem/883179/ilegal-characters-in-path-after-fresh-install.html Somehow, a registry key contains invalid path characters. This causes an `ArgumentException` from `AndroidSdkWindows.CheckRegistryKeyForExecutable()`: System.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) at System.IO.Path.Combine(String path1, String path2) at Xamarin.Android.Tools.AndroidSdkWindows.CheckRegistryKeyForExecutable(UIntPtr key, String subkey, String valueName, Wow64 wow64, String subdir, String exe) at Xamarin.Android.Tools.AndroidSdkWindows.<GetAllAvailableAndroidSdks>d__37.MoveNext() at System.Linq.Enumerable.<DistinctIterator>d__64`1.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at Xamarin.Android.Tools.AndroidSdkBase.get_AllAndroidSdks() at Xamarin.Android.Tools.AndroidSdkBase.Initialize(String androidSdkPath, String androidNdkPath, String javaSdkPath) at Xamarin.Android.Tools.AndroidSdkWindows.Initialize(String androidSdkPath, String androidNdkPath, String javaSdkPath) at Xamarin.Android.Tools.AndroidSdkInfo..ctor(Action`2 logger, String androidSdkPath, String androidNdkPath, String javaSdkPath) Handle the `ArgumentException` by wrapping the body of `CheckRegistryKeyForExecutable()` within a `try/catch` block and catch all exceptions. If an exception is thrown, there is no executable of interest.
In https://developercommunity.visualstudio.com/content/problem/883179/ilegal-characters-in-path-after-fresh-install.html, the user is hitting an exception when checking for an executable from paths found in their registry.
If we hit an error we should just return
false
as there obviously isn't a valid install located there.