Error HRESULT E_FAIL has been returned from a call

2020-01-27 01:58发布

I have a problem debugging a project migrated from Visual Studio 2010 to 2012. Every time I go to debug it I get the error message:

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

Compiling and running the application in a local IIS server works fine - just cannot debug.

The other change other than moving to VS2012 is I am now using Team Foundation Server for source control and issue tracking - but I cannot see how that would affect it.

I can narrow it down to the following

  • The project file - it has been migrated from VS 2003 as a website project and has been chopped and changed up the different versions
  • Crystal Report runtime library/ some other library

Anyone with any ideas?

30条回答
祖国的老花朵
2楼-- · 2020-01-27 02:27

I find this answer click Ctrl+Alt+J click (...) in the top now you can add dll from Browse , .Net or another After clicking the OK button click at (add to references in selected Project in solution explorer) (this is a green plus "+" button)

查看更多
SAY GOODBYE
3楼-- · 2020-01-27 02:29

I have been getting this a lot lately i've been having to create a new file and move the code to the new file to get around it.

But i found a quick, easy and painless fix.

In my particular case, i delete the solution's suo file (as far as i can tell just stores info like what files are open in the IDE and stuff so no real damage to delete it). My file was seemingly corrupt (IDE wouldn't remember what files were open when restarting, it was 1.7meg in size which seems large even for my 40 project solution, which rarely has more than 50 files open at once).

To summarize: Deleting the .suo file while VS was closed, fixed the E_FAIL issue i was getting opening my winforms file in designer mode.

Edit:

I just recently had to do this in VS2017 but for another reason, it was taking longer to build and took 5+ minutes to stop a debug session, deleting that pesky suo file fixed it right up, now anytime VS acts weird deleting SUO is my first port of call.

查看更多
霸刀☆藐视天下
4楼-- · 2020-01-27 02:29

I got this error when trying to install a nuget package that I had previously downloaded and installed in another project.

Clicking Clear all NuGet Cache(s) under Tools > Options > NuGet Package Manager solved this for me

查看更多
Animai°情兽
5楼-- · 2020-01-27 02:30

It seems that to bring up the Add Reference dialog in Visual Studio 2017 the Microsoft.VisualStudio.Shell.Interop.11.0.dll needs to be regsitered in the GAC. You can follow these steps to register this assembly in the GAC:

Open the Develop Command Prompt for VS2017 (ensure you run the as administrator otherwise the GAC registration may fail)

Change the current directory to the PublicAssemblies folder for your Visual Studio 2017 installation. Mine was:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies

Run the following command to register the assembly in the GAC:

gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies>gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.0 Copyright (c) Microsoft Corporation. All rights reserved.

Assembly successfully added to the cache

Now restart VS2017 and try to add a reference to your project again and you should see the Add Reference dialog appear.

For more clarification please follow below link

https://camerondwyer.com/2017/05/03/how-to-fix-the-operation-could-not-be-completed-error-adding-reference-to-visual-studio-2017/#more-2286

查看更多
手持菜刀,她持情操
6楼-- · 2020-01-27 02:31

I wrote a simple program to open different folder while clicking on some specific buttons. I made the file properties as "content" and "copy if newer" to make deployment. So if I installed the exe file in the other software it actually install all of its resources and run the program fine. So, this is all about my program. While developing this sometimes if I run the program to check, it showed the error

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

and I could not open the designer view. But Somehow I got an easy solution for me. I am not sure whether it will work for other or not.

Here is the solution:

Copy the whole application folder to another location. click on the application file from there. it will not work since it is just a copy and you will not see the designer

  1. From the solution explorer delete the form1.vb ( or may be a different name if it was changed during developing)
  2. In the solution explorer>right click>add an existing item> browse the file Form1.vb from where the folder is copied ( orginal location)
  3. run the program in the new location. It will work

The problem with this solution if you want to add something and after running the program you find the same error, you have to copy the whole application folder in another location again and follow the above steps

查看更多
三岁会撩人
7楼-- · 2020-01-27 02:31

Steps to resolve the issue:

1.Open your solution/Web Application in VS 2012 in administrator mode.

2.Go to IIS and Note down the settings for your application (e.g.Virtual directory name, Physical Path, Authentication setting and App pool used).

3.Remove (right click and select Remove) your application from Default Web Site. Refresh IIS.

4.Go back to VS 2012 and open settings (right click and select properties) for your web application.

5.Select Web.In Servers section make sure you have selected "Use Local IIS Web Server".

6.In Project Url textbox enter your application path (http://localhost/Application Path). Click on Create Virtual Directory.

7.Go to IIS and apply settings noted in step 2. Refresh IIS.

8.Go to VS 2012 and set this project as startup Project with appropriate page as startup page.

9.Click run button to start project in debug mode.

This resolved issue for me for web application which was migrated from VS 2010 to 2012.Hope this helps anyone looking for specific issue.

My machine configuration is: IIS 7.5.7600.16385

VS 2012 Professional

Windows 7 Enterprise (Version 6.1 - Build 7601:Service Pack 1)

查看更多
登录 后发表回答