Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 全方位失败:Can';t创建任务';GetReferenceNearestTargetFrameworkTask';_C#_Visual Studio Code_Omnisharp - Fatal编程技术网

C# 全方位失败:Can';t创建任务';GetReferenceNearestTargetFrameworkTask';

C# 全方位失败:Can';t创建任务';GetReferenceNearestTargetFrameworkTask';,c#,visual-studio-code,omnisharp,C#,Visual Studio Code,Omnisharp,我使用的是带有C#扩展名的VSCode(检查过的版本-它是最新的-1.23.11),对此我非常满意。 然而,今天它突然停止工作(没有智能感知或导航)。 我检查了OmniSharp的日志,发现以下错误: Failed to create instance of task "GetReferenceNearestTargetFrameworkTask" from "C:\Program Files (x86)\Microsoft Visual Studio\2019\

我使用的是带有C#扩展名的VSCode(检查过的版本-它是最新的-1.23.11),对此我非常满意。 然而,今天它突然停止工作(没有智能感知或导航)。 我检查了OmniSharp的日志,发现以下错误:

Failed to create instance of task "GetReferenceNearestTargetFrameworkTask" 
from "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll".
Task assembly should be built with the same version of assembly Microsoft.Build.Framework, 
which is installed on computer, and in host should be set binding redirection for Microsoft.Build.Framework.
Failed to cast type "NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask" to type "Microsoft.Build.Framework.ITask".
这可能不是确切的文本-我得到了本地化的消息并翻译了它

然后我检查了哪些依赖项有“NuGet.Build.Tasks.dll”,它有“Microsoft.Build.Framework,4.0.0”。 我已经检查了哪些绑定重定向具有“Omnisharp.exe”OmniSharp.exe.config'包含:

      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="2.0.0.0-99.0.0.0" newVersion="15.1.0.0" />
      </dependentAssembly>

因此,重定向是存在的

我在“Omnisharp”中打开了“调试”日志,查看它是否加载了正确的“Microsoft.Build.Framework”,是的,它加载了正确的

我甚至试着在“Microsoft.CSharp.targets”中注释掉“GetReferenceNearestTargetFrameworkTask”,但在类似的情况下,它失败了,只是针对另一种类型的任务

有人能帮我处理一下吗,或者给我一些想法——检查什么? 最奇怪的是,它昨天晚上工作得很好,但今天失败了,我找不到任何可能破坏它的更新迹象

UPD我成功地克服了这个问题-从GAC中删除了
Microsoft.Build.Framework
assembly(4.0版本)。我仍然不明白为什么在使用设置了
bindingRedirect
OmniSharp.exe
进程时会尝试它