VS 2015 Issue with Console Apps

Just spent the past couple of days trying to get a legacy VS 2015 console app to debug. But whatever I tried CRM just kept returning the exception message “Unable to Login to Dynamics CRM” which is frankly a horribly generic catch-all error message that could mean absolutely anything!

After investigating and ruling out issues with connections strings, NuGet Packages, tooling connectors and other dependency issues I finally stumbled across this article (see 4th reply from “Justin Jose”) on the Microsoft CRM Dynamics Forum. Turns out there is a bug in VS 2015 and you can’t login to Dynamics via a Console App in debug mode! Thanks Microsoft – that’s two days of my life well spent!!!!

Seems the issue is related to the introduction of TLS 1.2 and does not impact built executables. Indeed running the console app in VS 2017 made the problem go away…