omn​​isharp with asp.net core 1.1 app

时间:2017-07-26 21:07:22

标签: c# vim mono .net-core omnisharp

我试图在vi(neovim)中获得asp.net核心1.1应用程序的代码完成

这是omnisharp服务器+ vim插件: https://github.com/OmniSharp/Omnisharp-vim

在我的.vimrc中我添加了这个:

Plug 'OmniSharp/omnisharp-vim'
let g:OmniSharp_server_type = 'roslyn'

(我认为我需要roslyn用于.net核心?)

我还克隆并编译了omnisharp roslyn服务器而没有错误 但是当我启动OmniSharp时,我收到了这个错误:

/.local/share/nvim/plugged/omnisharp-vim/omnisharp-roslyn> ./artifacts/scripts/OmniSharp
OmniSharp:
System.DllNotFoundException: System.Native
  at (wrapper managed-to-native) Interop+Sys:GetUnixNamePrivate ()
  at Interop+Sys.GetUnixName () [0x00000] in <2c0705c248b844f597694acdb70b3a23>:0
  at System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform (System.Runtime.InteropServices.OSPlatform osPlatform) [0x00009] in <2c0705c248b844f597694acdb70b3a23>:0
  at Microsoft.Extensions.Logging.Console.ConsoleLogger..ctor (System.String name, System.Func`3[T1,T2,TResult] filter, System.Boolean includeScopes) [0x00051] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider.CreateLoggerImplementation (System.String name) [0x00019] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <a33fd236349b4603bef9951b0ab37965>:0
  at Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider.CreateLogger (System.String name) [0x00000] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at Microsoft.Extensions.Logging.Logger.AddProvider (Microsoft.Extensions.Logging.ILoggerProvider provider) [0x00000] in <6ac0afe55b53462283fd4e4f8f1658ac>:0
  at Microsoft.Extensions.Logging.LoggerFactory.AddProvider (Microsoft.Extensions.Logging.ILoggerProvider provider) [0x00061] in <6ac0afe55b53462283fd4e4f8f1658ac>:0
  at Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsole (Microsoft.Extensions.Logging.ILoggerFactory factory, System.Func`3[T1,T2,TResult] filter, System.Boolean includeScopes) [0x00008] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsole (Microsoft.Extensions.Logging.ILoggerFactory factory, System.Func`3[T1,T2,TResult] filter) [0x00000] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at OmniSharp.Startup.Configure (Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.IServiceProvider serviceProvider, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, OmniSharp.Stdio.Services.ISharedTextWriter writer, OmniSharp.Services.IAssemblyLoader loader, Microsoft.Extensions.Options.IOptionsMonitor`1[TOptions] options) [0x00032] in <8853ad029e4d47c0b478044425f4b3a3>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <a33fd236349b4603bef9951b0ab37965>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a33fd236349b4603bef9951b0ab37965>:0
  at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure (Microsoft.AspNetCore.Builder.IApplicationBuilder app) [0x00027] in <24af31b64ae843689736582353a19b3a>:0
  at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter+<>c__DisplayClass0_0.<Configure>b__0 (Microsoft.AspNetCore.Builder.IApplicationBuilder builder) [0x0000d] in <24af31b64ae843689736582353a19b3a>:0
  at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication () [0x00080] in <24af31b64ae843689736582353a19b3a>:0
  at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize () [0x00008] in <24af31b64ae843689736582353a19b3a>:0
  at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build () [0x0008a] in <24af31b64ae843689736582353a19b3a>:0
  at OmniSharp.Program+<>c__DisplayClass1_0.<Run>b__1 () [0x00196] in <8853ad029e4d47c0b478044425f4b3a3>:0
  at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x0035b] in <e56ebbc3ed87488b8e26736bbadaa5d3>:0
  at OmniSharp.Program.Run (System.String[] args) [0x001ae] in <8853ad029e4d47c0b478044425f4b3a3>:0
  at OmniSharp.Program.Main (System.String[] args) [0x0001c] in <8853ad029e4d47c0b478044425f4b3a3>:0

以下是一些版本信息:

~> dotnet --info
.NET Command Line Tools (1.0.4)

Product Information:
 Version:            1.0.4
 Commit SHA-1 hash:  af1e6684fd

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/1.0.4
~> mono --version
Mono JIT compiler version 5.2.0.209 (2017-04/3d531ba Mon Jul  3 12:16:03 EDT 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug
    LLVM:          yes(3.6.0svn-mono-master/8b1520c)
    GC:            sgen (concurrent by default)
~>

为什么我甚至需要Mono? Isn的dotnet核心不够吗? dotnet核心只适用于Roslyn吗? vscode用于c#完成的是什么?罗斯林?
这可能是什么问题?

更新

我从roslyn文件夹(〜/ .local / share / nvim / plugged / omnisharp-vim / omnisharp-roslyn)发布了这样的文章:&#39; dotnet publish -c Release -f netcoreapp1.1&#39 ;

然后我将文件从发布文件夹(〜/ .local / share / nvim / plugged / omnisharp-vim / omnisharp-roslyn / artifacts / publish / OmniSharp / default / netcoreapp1.1)复制到脚本文件夹(〜 /.local/share/nvim/plugged/omnisharp-vim/omnisharp-roslyn/artifacts/scripts)。

不确定这是否是正确的解决方案,但它似乎有效。

更新2:

最后我刚从这里下载了一个版本:https://github.com/OmniSharp/omnisharp-roslyn/releases

然后我将omnisharp-vim / omnisharp-roslyn / artifacts / scripts / OmniSharp改为:

#!/bin/bash
"/<path>/omnisharp-vim/omnisharp-osx-x64-netcoreapp1.1/Omnisharp" "$@"

现在可行了

1 个答案:

答案 0 :(得分:1)

通常会发生System.DllNotFoundException: System.Native异常,因为您刚刚复制了编译文件夹,这是错误的,您必须发布应用程序,然后使用该文件夹中的文件,应用程序中将有所有库需要运行。