0

尝试使用 vim 使用新的omnisharp。

我目前的设置是带有omnisharp-vim的vim。那些直接在项目目录中手动启动omnisharp-server客户端的github页面(因此它可以索引所有.cs文件),然后尝试使用vim。

问题是我无法启动omnisharp-server。

按照 github 页面上的步骤操作后:https ://github.com/OmniSharp/omnisharp-server

我收到以下错误(从 vim 捆绑目录或只是新克隆和 xbuilt 目录运行)

HelloMvc>$ mono ~/.vim/bundle/Omnisharp/server/OmniSharp/obj/Debug/OmniSharp.exe -s .

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Nancy.Hosting.Self,
Version=0.22.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Nancy.Hosting.Self, Version=0.22.2.0, Culture=neutral, PublicKeyToken=null'
at OmniSharp.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly
'Nancy.Hosting.Self, Version=0.22.2.0, Culture=neutral, PublicKeyToken=null' or one of its     
dependencies.
File name: 'Nancy.Hosting.Self, Version=0.22.2.0, Culture=neutral, PublicKeyToken=null'
at OmniSharp.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

所以看起来单声道没有 Nancy.Hosting.Self 程序集?

所以我手动下载了 Nancy 项目并尝试构建它并得到了这个错误:

/Users/me/seesharp/Nancy/src/Nancy.sln (default targets) ->
(Build target) ->
/Users/me/seesharp/Nancy/src/Nancy.Hosting.Wcf/Nancy.Hosting.Wcf.csproj (default targets) ->
/usr/local/Cellar/mono/3.10.0/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->

NancyWcfGenericService.cs(65,31): error CS1061: Type `System.ServiceModel.Web.WebOperationContext' 
does not contain a definition for `CreateStreamResponse' and no extension method 
`CreateStreamResponse' of type `System.ServiceModel.Web.WebOperationContext' could be found. Are you 
missing an assembly reference?

好的,这很奇怪,因为 github 页面说它正在构建,所以让我们看看失败的代码:

[WebInvoke(UriTemplate = "*", Method = "*")]
    public Message HandleRequests(Stream requestBody)
    {
        var webContext = WebOperationContext.Current;

        var nancyRequest = 
            CreateNancyRequestFromIncomingWebRequest(webContext.IncomingRequest, requestBody, OperationContext.Current);

        var nancyContext = 
            engine.HandleRequest(nancyRequest);

        SetNancyResponseToOutgoingWebResponse(webContext.OutgoingResponse, nancyContext.Response);

        return webContext.CreateStreamResponse(
            stream =>
                {
                    nancyContext.Response.Contents(stream);
                    nancyContext.Dispose();
                }, 
                nancyContext.Response.ContentType ?? string.Empty);
    }

并在文件顶部

    using System.ServiceModel.Web;

该引用也存在于项目 .csproj 文件中。

那么发生了什么事,如果我在错误的方向上走得太远,我怎样才能让omnisharp-server 工作,同时等待omnisharp-vim 或youcompleteme 插件解决这个问题?

编辑:好的,所以在尝试了 mvcmusicstore 应用程序并加载它之后,我看到 vim 说它运行单声道的方式是这样的:

mono '/Users/me/.vim/bundle/Omnisharp/server/OmniSharp/bin/Debug/OmniSharp.exe' -p 2000 -s .

但这给了我以下错误: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at OmniSharp.Solution.CSharpProject.AddReference (IAssemblyReference reference) [0x00000] in <filename unknown>:0 at OmniSharp.Solution.CSharpProject.AddMsCorlib () [0x00000] in <filename unknown>:0 at OmniSharp.Solution.CSharpProject..ctor (ISolution solution, OmniSharp.Logger logger, System.String folderPath) [0x00000] in <filename unknown>:0 at OmniSharp.Solution.CSharpFolder.LoadSolution () [0x00000] in <filename unknown>:0 at OmniSharp.Program.StartServer (System.String solutionPath, System.String clientPathMode, Int32 port, Verbosity verbosity, System.String configLocation) [0x00000] in <filename unknown>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object at OmniSharp.Solution.CSharpProject.AddReference (IAssemblyReference reference) [0x00000] in <filename unknown>:0 at OmniSharp.Solution.CSharpProject.AddMsCorlib () [0x00000] in <filename unknown>:0 at OmniSharp.Solution.CSharpProject..ctor (ISolution solution, OmniSharp.Logger logger, System.String folderPath) [0x00000] in <filename unknown>:0 at OmniSharp.Solution.CSharpFolder.LoadSolution () [0x00000] in <filename unknown>:0 at OmniSharp.Program.StartServer (System.String solutionPath, System.String clientPathMode, Int32 port, Verbosity verbosity, System.String configLocation) [0x00000] in <filename unknown>:0

4

1 回答 1

0

原来这是omnisharp-vim的一个问题。

下载、构建和运行 omnisharp-server 解决方案为我解决了这个问题

编辑:这已在omnisharp-vim 插件中修复。拉最新并重建,你应该没问题。感谢维护者。

于 2014-12-17T03:42:24.433 回答