I am trying to enumerate all projects of a solution using Microsoft.VisualStuio.LanguageServices. This is working fine for VisualStudio 2019 but it is failing on VisualStudio 2017. My code is as bellow-
var workspace= ComponentModel.GetService<Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace>();
var projects = workspace.CurrentSolution.Projects;
I am getting exception in the second line -
System.ArgumentNullException: 'Value cannot be null. Parameter name: source'
It shows list of projects on debug though. I am using Microsoft.VisualStudio.LanguageServices.dll of 2.10.0.0 version which is same as loaded dll in VS module. Is it a assembly issue? How can I fix this?