首先,我已经尝试了Getting "Error: Failed to connect to OmniSharp"中列出的步骤,并按照所提及的reddit帖子中发布的说明进行操作。
我在OS X Yosemite上安装了VSCode,加载sln时出现此错误。
Error: Failed to connect to OmniSharp
我知道OmniSharp安装了VSCode,但我也安装了Mono以及使用brew安装的dnvm,aspnet / dnx。
有人可以提出建议吗?我喜欢VSCode的外观和感觉,阅读文档后可以看出它有一些很棒的功能。我耐心等待在我的macbook上做我的c#工作,真的很期待能够尝试VSCode。
感谢您的任何建议。
以下是我的OmniSharp日志的输出:
Starting OmniSharp at '/Volumes/cca/cca.sln'...
[INFORMATION:OmniSharp.Startup] Omnisharp server running on port '2000' at location '/Volumes/cca' on host 930.
[INFORMATION:OmniSharp.AspNet5.AspNet5Paths] Using runtime '/Users/jayrue/.dnx/runtimes/dnx-mono.1.0.0-beta4'.
[INFORMATION:OmniSharp.AspNet5.AspNet5ProjectSystem] Scanning '/Volumes/cca' for ASP.NET 5 projects
[INFORMATION:OmniSharp.AspNet5.AspNet5ProjectSystem] No project.json based projects found
[INFORMATION:OmniSharp.MSBuild.MSBuildProjectSystem] Detecting projects in '/Volumes/cca/cca.sln'.
[WARNING:OmniSharp.MSBuild.MSBuildProjectSystem] Skipped unsupported project type 'http://localhost:63367'
这是我的sln:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Web
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "cca", "http://localhost:63367", "{53236049-2FD4-436E-B20D-8E53D6F9EC7E}"
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "true"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv2.0"
Debug.AspNetCompiler.VirtualPath = "/localhost_63367"
Debug.AspNetCompiler.PhysicalPath = "E:\inetpub\wwwroot\cca\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_63367\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/localhost_63367"
Release.AspNetCompiler.PhysicalPath = "E:\inetpub\wwwroot\cca\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_63367\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
SlnRelativePath = "E:\inetpub\wwwroot\cca\"
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{53236049-2FD4-436E-B20D-8E53D6F9EC7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53236049-2FD4-436E-B20D-8E53D6F9EC7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
答案 0 :(得分:1)
您需要project.json文件。这是VSCode理解的项目文件格式。它不了解sln格式。
答案 1 :(得分:0)
对于MSBuild工作区(具有sln
- 文件的工作区),VSCode支持csproj
- 文件。您发布的解决方案仅指向WebSite项目({E24C65DC-7377-472B-9ABA-BC803B73C61A}
,http://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs)。如前所述,另一种方法是带有project.json
文件的DNX工作区。
答案 2 :(得分:0)
尝试打开整个项目文件夹而不是.sln文件。转到文件>打开,而不是进入项目文件夹,单击它一次以选择它,然后单击打开。 Visual Studio Code将尝试自动加载该文件夹中的所有相关文件。
答案 3 :(得分:0)
OmniSharpServer在端口2000上运行,但ycm客户端使用随机端口与服务器连接。这是失败的原因。
进行以下更改将解决此问题:
文件: THIRD_PARTY /永煤集团/永煤集团/完成者/ CS / cs_completer.py
""" Start the OmniSharp server """
self._logger.info( 'startup' )
- self._omnisharp_port = utils.GetUnusedLocalhostPort()
+ #self._omnisharp_port = utils.GetUnusedLocalhostPort()
+ self._omnisharp_port = 2000
然后删除cs_completer.pyc并重试。