VS代码Omnisharp.MsBuild.Projectmanager无法加载程序集System.Numerics.Vectors 4.1.3.0

我在打开一个新创建的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,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,IPropertyProvider`1 properties,ExpanderOptions options,UsedUninitializedProperties usedUninitializedProperties,IFileSystem fileSystem)
   bij microsoft.build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression,IFileSystem fileSystem)
   bij microsoft.build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression,IFileSystem fileSystem)
   bij microsoft.build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression,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,Boolean accumulateProperties)
   bij microsoft.build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets,Boolean accumulateProperties)
   bij microsoft.build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets,String& msBuildOverridetasksPath,String& defaultOverrideToolsVersion)
   bij microsoft.build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets,ToolsetRegistryReader registryReader,ToolsetConfigurationReader configurationReader,PropertyDictionary`1 environmentProperties,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警告。

我不知道为什么我的PC上出现此错误。

有人有主意吗?

谢谢!

iCMS 回答:VS代码Omnisharp.MsBuild.Projectmanager无法加载程序集System.Numerics.Vectors 4.1.3.0

问题是Visual Studio Code(由OmniSharp提供支持)的VS Code Extension的C#中包含的MSBuild无法在系统上正确定位System.Numerics.Vectors的特定4.1.3.0版本。

最简单的解决方案是安装包含该版本的System.Numerics.Vectors程序集的.NET Core SDK 3.1.301,然后进行复制

C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\System.Numerics.Vectors.dll

%USERPROFILE%\.vscode\extensions\ms-dotnettools.csharp-1.22.1\.omnisharp\1.35.3\.msbuild\Current\Bin

此问题可能会在Visual Studio Code(由OmniSharp支持)VS Code Extension的C#更高版本中解决

,

您可以在GAC中安装的必要版本的runtime的{​​{1}}部分中添加

MSBuild.exe.config

要检查主机上安装的版本,请执行以下操作:

<dependentAssembly> <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /> </dependentAssembly> <dependentAssembly>

通常位于SDK gacutil.exe -l System.Numerics.Vectors中的gacutil

,

只需在C:\ Windows \ Microsoft.NET \ assembly \ GAC_MSIL \ System.Numerics.Vectors \ v4.0_4.1.3.0__b03f5f7f11d50a3a中添加正确版本的DLL

本文链接:https://www.f2er.com/2025950.html

大家都在问