【问题标题】:omnisharp with asp.net core 1.1 app带有 asp.net core 1.1 应用程序的omnisharp
【发布时间】:2017-07-26 21:07:21
【问题描述】:

我正在尝试在 vi (neovim) 中为 asp.net core 1.1 应用程序完成代码

这里是omnisharp server + vim 插件: https://github.com/OmniSharp/Omnisharp-vim

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

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

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

我还克隆并编译了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" "$@"

现在可以了

【问题讨论】:

  • “OmniSharp 可以在 Windows 和 Linux 以及带有 Mono 的 OS X 上运行。”来自存储库,因此它没有说明与 .net Core 兼容,这就是您需要 mono 的原因,mono 是 .net Classic 的一个端口,.net Core 在内部非常不同。问题通常是因为您没有发布代码并且缺少文件,请尝试“dotnet publish -c Release”并使用发布文件夹文件(所有这些文件)
  • 您的意思是从 roslyn 文件夹运行 'dotnet publish -c Release -f netcoreapp1.1',然后将文件从 'artifacts/publish/OmniSharp/default/netcoreapp1.1' 复制到脚本文件夹?
  • 不确定你的项目有什么结构...
  • 这是omnisharp-roslyn的结构,但它似乎是这样工作的。如果您从您的评论中创建答案,那么我会接受它。

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2018-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-17
    • 1970-01-01
    • 1970-01-01
    • 2017-12-08
    相关资源
    最近更新 更多