【发布时间】:2020-06-30 18:28:42
【问题描述】:
我在打开新创建的 blazorwasm 项目时遇到问题。 Omnisharp 将无法正确启动。这是输出:
[warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file 'c:\VS.NET2010\CoreApp\Server\CoreApp.Server.csproj'.
c:\VS.NET2010\CoreApp\Server\CoreApp.Server.csproj(1,1)
System.IO.FileLoadException: Kan bestand of assembly System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a of een van de afhankelijkheden hiervan niet laden. De manifestdefinitie van de gevonden assembly komt niet overeen met de assembly-verwijzing. (Uitzondering van HRESULT: 0x80131040)
Bestandsnaam: System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
bij System.SpanHelpers.IndexOf(Char& searchSpace, Char value, Int32 length)
bij Microsoft.Build.Evaluation.Expander`2.Function`1.ExtractPropertyFunction(String expressionFunction, IElementLocation elementLocation, Object propertyValue, UsedUninitializedProperties usedUnInitializedProperties, IFileSystem fileSystem)
bij Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
bij Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
bij Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
bij Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
bij Microsoft.Build.Evaluation.ToolsetReader.ExpandPropertyUnescaped(ToolsetPropertyDefinition property, Expander`2 expander)
bij Microsoft.Build.Evaluation.ToolsetReader.EvaluateAndSetProperty(ToolsetPropertyDefinition property, PropertyDictionary`1 properties, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& toolsPath, String& binPath, Expander`2& expander)
bij Microsoft.Build.Evaluation.ToolsetReader.ReadToolset(ToolsetPropertyDefinition toolsVersion, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
bij Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
bij Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& msBuildOverrideTasksPath, String& defaultOverrideToolsVersion)
bij Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations)
bij Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader registryReader, ToolsetConfigurationReader configReader)
bij Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly)
bij Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
bij OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:regel 123
bij OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:regel 72
bij OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectIdInfo projectIdInfo, ProjectLoader loader, Guid sessionId, IDotNetCliService dotNetCli) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectFile\ProjectFileInfo.cs:regel 113
bij OmniSharp.MSBuild.ProjectManager.<>c__DisplayClass31_0.<LoadProject>b__0() in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:regel 302
bij OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:regel 313
WRSCH: registratie van assembly-bindingen is uitgeschakeld.
Als u assembly-bindingsfouten wilt registreren, stelt u de registerwaarde [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) in op 1.
Opmerking: er is een prestatiestraf gekoppeld aan de registratie van assembly-bindingsfouten.
Als u deze functie wilt uitschakelen, verwijdert u de registerwaarde [HKLM\Software\Microsoft\Fusion!EnableLog].
这是 csproj 文件:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Client\CoreApp.Client.csproj" />
<ProjectReference Include="..\Shared\CoreApp.Shared.csproj" />
</ItemGroup>
</Project>
我不知道为什么会出现此错误。因此,我无法在此项目中使用 IntelliSense。
我的一个同事没有这个问题。他可以使用以下命令创建一个类似的项目:
dotnet new blazorwasm -o CoreApp --hosted
在他的 PC 上,项目可以正常打开,没有任何 OmniSharp 警告。
我不知道为什么我的电脑会出现此错误。
有人有想法吗?
提前致谢!
【问题讨论】:
-
今天和同事有同样的问题。在我的环境中(很久以前设置的 VS Code、.NET Core 和 Omnisharp Extension,但已更新到最新版本)一切正常。在他的 PC(今天设置)上,每个 C# 项目都会出现错误。大多数使用“dotnet new console”创建的简单控制台应用程序也会发生这种情况。因此我猜这是当前版本的 Omnisharp 的一个错误。
-
感谢您的评论!我尝试了各种方法,我也认为这是当前版本 1.22.1 中的一个错误(根据我在 VS Code 中看到的 Changelog 尚未发布:p)。希望他们很快会发布另一个版本。仍然欢迎任何其他建议。我还在寻找解决方案,如果找到了会发布。如果您的同事找到解决方案,请告诉我。
标签: c# .net visual-studio-code csproj omnisharp