【问题标题】:System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjectionSystem.IO.FileNotFoundException:无法加载文件或程序集'Microsoft.Extensions.DependencyInjection
【发布时间】:2021-04-02 10:12:26
【问题描述】:

我正在使用 Visual Studio Code 来运行创建我的 Angular 和 .Net Core Web 应用程序。当我写终端“dotnet -v”然后我发现我的机器已经安装了.net core 5。然后我在VS Code终端中写了“dotnet new angular”,然后结合创建了angular和dot.net core项目。然后我运行我的应用程序,然后成功运行。但问题是当我在“控制器”代码或“模型”.cs 扩展代码中编写代码时。当我编写代码时,在鼠标单击后我没有找到任何建议的添加命名空间的操作。另外,我尝试ctrl .,但我显示 No Code Action Available。如果我写了一个错误代码,那么它没有按预期显示任何红色错误行。

这是我在 Visual Studio Code 中的终端输出:-


Starting OmniSharp server at 4/2/2021, 3:47:49 PM
    Target: c:\Users\Hp\Desktop\Summaries

OmniSharp server started.
    Path: c:\Users\Hp\.vscode\extensions\ms-dotnettools.csharp-1.23.9\.omnisharp\1.37.6\OmniSharp.exe
    PID: 7372

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Extensions.DependencyInjection, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at OmniSharp.CompositionHostBuilder.CreateDefaultServiceProvider(IOmniSharpEnvironment environment, IConfigurationRoot configuration, IEventEmitter eventEmitter, IServiceCollection services, Action`1 configureLogging)
   at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1() in D:\a\1\s\src\OmniSharp.Stdio.Driver\Program.cs:line 56
   at OmniSharp.HostHelpers.Start(Func`1 action) in D:\a\1\s\src\OmniSharp.Host\HostHelpers.cs:line 29

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).


我是一个绝对的初学者。我如何解决这个问题。

【问题讨论】:

    标签: c# asp.net-core asp.net-web-api visual-studio-code asp.net-core-mvc


    【解决方案1】:

    您的问题是 VS 代码更新问题。对于更新问题,您的 .Net 调试器、.net razor 也无法下载您的机器。通常 Windows 10 会自动更新 VS 代码。所以我假设不知何故未能更新你的 vs 代码。

    之后重新启动你的 VS 代码。然后再次运行,您将看到 vs 输出正在下载所需的包。并解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-28
      • 2023-02-07
      • 1970-01-01
      • 2012-12-28
      • 2016-08-16
      • 2015-07-28
      相关资源
      最近更新 更多