Unable to start omnisharp-server on osx

1.8k Views Asked by At

Trying to work with the new omnisharp using vim.

My current setup is vim with omnisharp-vim. The github pages for those direct toward initiating the omnisharp-server client manually in the project directory (so it can index all the .cs files), and then attempting to use vim.

Problem is I can't start the omnisharp-server.

After following the steps on the github page: https://github.com/OmniSharp/omnisharp-server

I get the following error (running from the vim bundle directory or just a newly cloned and xbuilt directory)

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

So it appears that mono doesn't have the Nancy.Hosting.Self assembly?

So I manually downloaded the Nancy project and attempted to build it and got this error:

/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?

ok that's weird since the github page says it's building, so let's see the code that's failing:

[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);
    }

and at the top of the file

    using System.ServiceModel.Web;

The reference is also present in the projects .csproj file.

So what is going on, and if I've gone too far in the wrong direction, how can I get omnisharp-server to work while I wait for a fix in either the omnisharp-vim or youcompleteme plugins that take care of this?

edit: Ok so after trying out the mvcmusicstore app and loading that, I see that the way vim says it's running mono is like this:

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

but this is giving me the following error: 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

1

There are 1 best solutions below

0
On

Turns out that this is an issue with omnisharp-vim.

Downloading, building, and running the omnisharp-server solution fixed this issue for me

Edit: This has been fixed in the omnisharp-vim plugin. Pull latest and rebuild and you should be fine. Thanks to the maintainer.