1

我正在尝试在 vi (neovim) 中为 asp.net core 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?dotnet core 还不够吗?
dotnet core 是否仅适用于 Roslyn?
vscode 用什么来完成 c# 补全?罗斯林?
这里可能是什么问题?

更新:

我从 roslyn 文件夹 (~/.local/share/nvim/plugged/omnisharp-vim/omnisharp-roslyn) 进行了发布,如下所示:'dotnet publish -c Release -f netcoreapp1.1'

然后我将文件从发布文件夹(~/.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" "$@"

现在它可以工作了

4

1 回答 1

2

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

于 2017-07-26T21:43:22.543 回答