Error HRESULT E_FAIL when pasting references in Visual Studio

家住魔仙堡 提交于 2019-12-01 15:35:34

问题


I know this isn't a programming question but it is a programming tool question.

In Visual Studio 2008 Team Edition (version 9.0 with .NET 3.5 SP1) when I copy and paste references from one csproj to another (with the context menu in the 'Solution Explorer' view) I get the following error:

Error HRESULT E_FAIL has been returned from a call to a COM component

This has only just started happening on my machine. I can only find this article about it, and it contains no solution.

Any ideas?


回答1:


Yikes , E_FAIL is the most generic COM error , since it literally means a COM function returned fail. I would guess that somehow , visual studio 2008 has a corrupted COM object somewhere.

Have you tried reinstalling visual studio 2008 just to get it to re-register all its tlb's and objects ?




回答2:


This is the #1 hit that shows up on Google for VS 2010 paste reference E_FAIL and the like, so I thought I would share this workaround:

Don't use copy/paste references via the context menu in Solution Explorer.

Instead:

  1. Use the context menu to unload the project to copy references from.
  2. Edit the project file (.csproj; it's just XML).
  3. Find the reference(s) you are interested in and copy the <Reference> XML node(s).
  4. Unload the project to copy the reference into.
  5. Edit the project file (.csproj)
  6. Paste the reference copied in the previous step into appropriate location. You need to look for the <ItemGroup> node containing something like <Reference Include="mscorlib" />, and paste your reference just above it.
  7. Close both .csproj files, saving the just-modified target one as well.
  8. Reload both projects via Solution Explorer context-menu.

Your reference is now copied into the target project.

Apparently, at the very minimum, there is a problem with references that use environment variables, as described here (although in my case, I was having a problem with references that did not use environment variables, and in Visual Studio 2010...)



来源:https://stackoverflow.com/questions/1459111/error-hresult-e-fail-when-pasting-references-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!