'Expected Global Line.' 使用 Roslyn 加载解决方案时出现异常
'Expected Global Line.' exception while loading solution using Roslyn
我正在学习 Roslyn 并第一次试用它。我编写了一个小代码片段来加载解决方案并获取对作品的引用space。
IWorkspace workspace = Workspace.LoadSolution(solutionPath);
foreach (IProject project in workspace.CurrentSolution.Projects)
{
CommonCompilation objCompilation = project.GetCompilation();
}
return workspace;
但是我在第一行遇到异常。异常详情如下。
Message : Expected Global Line.
stack trace :
at
Roslyn.Services.Host.SolutionFile.ParseGlobal(TextReader reader)
at Roslyn.Services.Host.SolutionFile.Parse(TextReader reader)
at
Roslyn.Services.Host.LoadedWorkspace.LoadSolution(SolutionId
solutionId, String filePath)
at
Roslyn.Services.Host.LoadedWorkspace.OpenSolution(String fileName)
at Roslyn.Services.Host.LoadedWorkspace.LoadSolution(String
solutionFileName, String configuration, String platform, Boolean
enableFileTracking)
at
Roslyn.Services.Workspace.LoadSolution(String solutionFileName, String
configuration, String platform, Boolean enableFileTracking)
at
Ros2.Program.GetWorkspace(String solutionPath) in
c:\users\amnatu\documents\visual studio
2015\Projects\Ros2\Ros2\Program.cs:line 30
I referred to this link 这显示了我遇到的相同问题。但是,删除 EndProject
和 Global
之间的 space 的解决方案并不适用于我的情况,因为我的解决方案文件之间没有任何 space。
我在这里遗漏了什么吗?
关于如何解决这个问题有什么建议吗?
对延迟回复表示歉意。 @JoshVarty 的评论帮助我理解了这个问题。
我确实使用过时的版本,不得不使用最新的 Microsoft.CodeAnalysis
库。在我进行了这些更改并相应地更新了所有 类 之后,一切正常。
谢谢 JoshVarty!
我正在学习 Roslyn 并第一次试用它。我编写了一个小代码片段来加载解决方案并获取对作品的引用space。
IWorkspace workspace = Workspace.LoadSolution(solutionPath);
foreach (IProject project in workspace.CurrentSolution.Projects)
{
CommonCompilation objCompilation = project.GetCompilation();
}
return workspace;
但是我在第一行遇到异常。异常详情如下。
Message : Expected Global Line.
stack trace :
at Roslyn.Services.Host.SolutionFile.ParseGlobal(TextReader reader)
at Roslyn.Services.Host.SolutionFile.Parse(TextReader reader)
at Roslyn.Services.Host.LoadedWorkspace.LoadSolution(SolutionId solutionId, String filePath)
at Roslyn.Services.Host.LoadedWorkspace.OpenSolution(String fileName)
at Roslyn.Services.Host.LoadedWorkspace.LoadSolution(String solutionFileName, String configuration, String platform, Boolean enableFileTracking)
at Roslyn.Services.Workspace.LoadSolution(String solutionFileName, String configuration, String platform, Boolean enableFileTracking)
at Ros2.Program.GetWorkspace(String solutionPath) in c:\users\amnatu\documents\visual studio 2015\Projects\Ros2\Ros2\Program.cs:line 30
I referred to this link 这显示了我遇到的相同问题。但是,删除 EndProject
和 Global
之间的 space 的解决方案并不适用于我的情况,因为我的解决方案文件之间没有任何 space。
我在这里遗漏了什么吗?
关于如何解决这个问题有什么建议吗?
对延迟回复表示歉意。 @JoshVarty 的评论帮助我理解了这个问题。
我确实使用过时的版本,不得不使用最新的 Microsoft.CodeAnalysis
库。在我进行了这些更改并相应地更新了所有 类 之后,一切正常。
谢谢 JoshVarty!