2

首先,我已经尝试了获取“错误:无法连接到 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
4

4 回答 4

1

您需要 project.json 文件。也就是 VSCode 理解的项目文件格式。它不理解 sln 格式。

于 2015-05-06T00:40:38.833 回答
0

对于 MSBuild 工作区(带有sln-file 的工作区),VSCode 支持csproj-files。您发布的解决方案只是指向一个网站项目({E24C65DC-7377-472B-9ABA-BC803B73C61A}http://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs 。如前所述,另一种选择是带有project.json-files 的 DNX 工作区。

于 2015-05-06T12:42:09.817 回答
0

尝试打开整个项目文件夹而不是 .sln 文件。转到文件>打开,而不是进入项目文件夹,单击它一次以选择它,然后单击打开。Visual Studio Code 将尝试自动加载该文件夹中的所有相关文件。

于 2015-05-08T01:24:42.970 回答
0

OmniSharpServer 在端口 2000 上运行,但 ycm 客户端使用随机端口与服务器连接。这是失败的原因。

进行以下更改将解决此问题:

文件:third_party/ycmd/ycmd/completers/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 并重试。

于 2016-07-21T08:49:08.140 回答