visual-studio 找不到引用的组件“系统”。(或与此相关的任何其他组件)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/710890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:20:08  来源:igfitidea点击:

The referenced component 'System' could not be found. (or any other component for that matter)

visual-studiovisual-studio-2008

提问by Davy8

Issue:Just started today, all references to any assembly outside of the solution fail to resolve, with The referenced component 'SomeComponent' could not be found.when trying to build. This happens for both 3rd party components (all 15 or so of them) as well as all .NET Framework assemblies - basically anything that isn't another project in the same solution.

问题:今天刚开始,The referenced component 'SomeComponent' could not be found.在尝试构建时,对解决方案之外的任何程序集的所有引用都无法解析。这对于 3rd 方组件(全部 15 个左右)以及所有 .NET Framework 程序集都会发生 - 基本上不是同一解决方案中的另一个项目的任何东西。

Trying to load some other solutions produced the same issue. Creating a new WinForms project worked without a problem, however. (Scratch that, it worked before reinstalling VS, now that doesn't work either. I created a new WinForms app as well as a WPF app, and the designer can't load the assemblies either. I tried targetting 3.5 and 2.0 and no luck.)

尝试加载其他一些解决方案产生了同样的问题。然而,创建一个新的 WinForms 项目没有问题。(从头开始,它在重新安装 VS 之前工作,现在也不起作用。我创建了一个新的 WinForms 应用程序和一个 WPF 应用程序,设计器也无法加载程序集。我尝试定位 3.5 和 2.0,但没有运气。)

Things I've tried:

我尝试过的事情:

  • Repair Visual Studio installation
  • Rebooting computer
  • Started VS with /resetsettings flag
  • System Restore to 2 days ago when it was known to be working
  • Uninstalling VS and reinstalling
  • Fresh checkout from SVN
  • 修复 Visual Studio 安装
  • 重启电脑
  • 使用 /resetsettings 标志启动 VS
  • 系统还原到 2 天前,当时已知它可以正常工作
  • 卸载VS并重新安装
  • 从 SVN 新鲜结帐

Does anyone have any experience with this and know of a way to get this working again? My strongest Google-fu has failed me, so I'm asking here. Can mark community wiki if requested.

有没有人有这方面的经验并知道如何让它再次工作?我最强大的 Google-fu 失败了,所以我在这里问。如果需要,可以标记社区维基。

Update: I tried "upgrading" Windows (to the same version) since I didn't see a repair option for Vista and it's still a no-go. I reinstalled everything that seemed relevant. So far, it's looking like I'm just gonna have to back up and reformat I guess unless a solution comes up sometime before tomorrow.

更新:我尝试“升级”Windows(到相同版本),因为我没有看到 Vista 的修复选项,但它仍然是不行的。我重新安装了所有看起来相关的东西。到目前为止,看起来我只需要备份和重新格式化我猜除非在明天之前的某个时间出现解决方案。

Update2: I just backed up data and reformatted, so I'm no longer able to verify any ideas that I haven't tried yet, so I'll just leave the bounty to expire on its own to the top voted answer and as a reference to anyone else who may have this problem later.

更新 2:我刚刚备份了数据并重新格式化,所以我不再能够验证我还没有尝试过的任何想法,所以我只会让赏金自行过期给最高投票的答案,并作为参考以后可能遇到此问题的任何其他人。

采纳答案by chaos

Suggested next debug step: review Project Designer: References -> Reference Pathsto verify that the paths to your system and third-party components appear correctly. (Watch out for things that can slip past the old Mark I Eyeball like drive letters.)

建议的下一个调试步骤:查看项目设计器:参考 -> 参考路径以验证系统和第三方组件的路径是否正确显示。(注意可能会滑过旧 Mark I Eyeball 的东西,例如驱动器字母。)

回答by Benjamin J?hn

I had the same problem. It turns out that something was wrong with NuGet. I removed the following part of the *.csproj-File (opened in a text editor). This has solved the issue for me:

我有同样的问题。事实证明,NuGet 出了点问题。我删除了*.csproj-File的以下部分(在文本编辑器中打开)。这为我解决了这个问题:

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
        <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>

回答by Nanki

In my case, the solution was completely different. It looked like it was an issue with NuGet paths (caused by my moving the project to a different solution and then back again.

就我而言,解决方案完全不同。看起来这是 NuGet 路径的问题(由于我将项目移动到不同的解决方案然后又返回。

I edited the .csproj and removed all references to NuGet and associated packages. I also removed the packages folder from the solution folder.

我编辑了 .csproj 并删除了对 NuGet 和相关包的所有引用。我还从解决方案文件夹中删除了包文件夹。

The system components then magically reappeared.

系统组件然后神奇地重新出现。

回答by MethodsofSanity

I had this similar issue not too long ago.

不久前我遇到了类似的问题。

I found that the issue was caused by git not properly creating .exe's when jumping from branch to branch(we have nuget.exe in a path and it was getting deleted/added when jumping branches). When you would try to run nuget, windows would throw a fit over the exe.

我发现这个问题是由 git 在从一个分支跳转到另一个分支时没有正确创建 .exe 引起的(我们在一个路径中有 nuget.exe 并且它在跳转分支时被删除/添加)。当您尝试运行 nuget 时,windows 会在 exe 上运行。

After reseting the branch many times, I finaly got the exe to run properly. Then I noticed that the security on all the directories in the repo had been reset, so I had to deal with that.

多次重置分支后,我终于让exe正常运行。然后我注意到 repo 中所有目录的安全性都被重置了,所以我不得不处理这个问题。

After all of that, visual studio then started to play nice.

在这一切之后,visual studio 开始发挥良好的作用。

Hoped this helps someone!

希望这对某人有所帮助!

回答by Paul Alexander

Try running VS after turing on Assembly load logging with fuslogvw. You'll be able to see additional errors captured by the runtime when it tries to locate and load the assemblies.

在使用 fuslogvw 打开程序集负载日志后尝试运行 VS。您将能够看到运行时在尝试定位和加载程序集时捕获的其他错误。

In Vista, you'll have to run fuslogvw as an administrator and somtimes specify an explicit path to save the logs.

在 Vista 中,您必须以管理员身份运行 fuslogvw,并且有时会指定一个显式路径来保存日志。

You can also try debugging Visual Studio by attaching to it from another instance, or with the basic debugger included with the .NET SDK.

您还可以尝试通过从另一个实例附加到 Visual Studio 或使用 .NET SDK 中包含的基本调试器来调试它。

回答by Harry

Well, if you click on the error, in VS 2012 RC, and then debug it, the error is gone...

好吧,如果你在VS 2012 RC中点击错误,然后调试它,错误就消失了......

回答by Marc Gravell

I hate to say it, but it sounds like the system is pretty borked. There has to be a point when it is quicker to reinstall the OS than it is to continue trying to fix the current install.

我不想这么说,但听起来系统很无聊。必须有一点,重新安装操作系统比继续尝试修复当前安装更快。

I just hope you take this in the right spirit... sorry.

我只是希望你以正确的精神接受这个......对不起。

回答by MosGeo

I know that this is an old question but it is still happening in the latest version of Visual Studio (2015). I fixed it in a different way that might not have been available back when the question was asked. Basically, it is related to the fact that VS can't find the .Net Library package. To fix in the latest version of Visual Studio (2015):

我知道这是一个老问题,但它仍在最新版本的 Visual Studio (2015) 中发生。我以不同的方式修复了它,当提出问题时可能无法使用。基本上,这与 VS 找不到 .Net Library 包的事实有关。在最新版本的 Visual Studio (2015) 中修复:

  • Right Click on your solution in the Solution Manager. Choose "Manage NuGet Packages for Solution..."
  • in the NuGet Window, go to "Installed".
  • If you have something related to Microsoft.Net such as "Microsoft.NetCore.UniversalWindowsPlatform", remember the name and uninstall the package.
  • Now go to the browse tab and find the package and install it again. Don't forget to select the correct needed project.
  • Everything should be ok now.
  • 在解决方案管理器中右键单击您的解决方案。选择“管理解决方案的 NuGet 包...”
  • 在 NuGet 窗口中,转到“已安装”。
  • 如果您有与 Microsoft.Net 相关的内容,例如“Microsoft.NetCore.UniversalWindowsPlatform”,请记住名称并卸载该软件包。
  • 现在转到浏览选项卡并找到该软件包并再次安装它。不要忘记选择正确的所需项目。
  • 现在一切都应该好了。

I hope this helps somebody!

我希望这对某人有所帮助!

回答by Metro Smurf

Shot in the dark here, but I've run into the same (similar) problem. The issue I ran into was related to having a 64bit machine and running a project that had a mixture of 64bit and 32bit 3rd party dll's. The solution was to ensure I had the correct bits (32v64) and then to have the project build in 32 bit mode: project properties > build > platform target: x86.

在这里在黑暗中拍摄,但我遇到了相同(类似)的问题。我遇到的问题与拥有一台 64 位机器并运行一个混合了 64 位和 32 位 3rd 方 dll 的项目有关。解决方案是确保我拥有正确的位 (32v64),然后以 32 位模式构建项目:项目属性 > 构建 > 平台目标:x86。

Another time this occurred I had to remove all the 64bit dll's and reinstall with the 32bit dll's

另一次发生这种情况时,我必须删除所有 64 位 dll 并使用 32 位 dll 重新安装

HTH's

HTH的

回答by Coderer

Check your output with ILDASM to make sure the references are showing up correctly -- compare them to an assembly that works, and see if anything jumps out at you.

使用 ILDASM 检查您的输出,以确保引用正确显示——将它们与有效的程序集进行比较,看看是否有任何内容出现在您身上。