Reputation: 2851
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
Anyone with any ideas?
Upvotes: 150
Views: 369085
Reputation: 436
I had the same error while trying to edit a winform UserControl.
I tried all previous answers and nothing helped.
In my case I had .cs files used by both, .Net, and .Net Framework [added as reference only]. Only after unloading the .Net Framework from solution - I managed to edit the .Net UI.
Upvotes: 0
Reputation: 3802
For anyone experiencing this with Windows 11 and Visual Studio 2022 check if you have OneDrive running.
OneDrive was hijacking the Users/Documents folder which contained the redirection.config for IISExpress. This was causing IISExpress to fail to load as it was unable to read this config file.
I uninstalled one drive and rebooted - after which the problem was resolved.
Upvotes: 1
Reputation: 209
I have worked my way through these solutions and have one more that may save some frustration. I just solved this problem.
In my case Visual Studio glitched out and somehow my project obtained a reference to its self. This reference will not show up in Project\Add Reference. Hence why it is so easy to miss. Instead you have to expand the references Tree on the solution explorer. you will see your project name in the list of references. Remove this and the Project will function again. Super annoying but that solved it.
Upvotes: -1
Reputation: 19
I also had similar issue and found all solutions not working on my system. I observed that I had 2 Visual Studio versions installed in my system (2012 and 2019). So I just uninstalled 2012 and restarted my system. Automatically this error is removed.
If you failed all the above solutions including the solution using the cmd line, then try this method.
Upvotes: -1
Reputation: 125
In my case, it seems it was because I stashed some files, but some related windows remained open.
Closing all windows and rebuilding solution fixed it for me.
Upvotes: 2
Reputation: 1450
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.
I fixed it by deleting the solution's suo file (as far as I can tell, it just stores info like what files are open in the IDE and stuff, and deleting it does no real damage).
My file was seemingly corrupt. (The IDE wouldn't remember what files were open when restarting. It was 1.7MB in size, which seems large, even for my 40 project solution, which rarely has more than 50 files open at once.)
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.
Upvotes: 87
Reputation: 1368
I had this problem updating from VS2017 to VS2019
For me the problem was simply solved by deleting the .VC.db
file of the project.
Upvotes: 0
Reputation: 848
I encountered this error after installing VS2019 but while trying to open a large solution (20+ projects), with both vcxproj and csproj projects, that target VS2015. The csproj all loaded fine, while the vcxproj all failed with the OP's error. Deleting the .vs folder did not work.
What did work was setting VC++'s "Fallback Location", under the "Browsing Database Fallback" settings.
Tools (menu)
-Options...
--Text Editor
---C/C++
---Advanced
----Browsing Database Fallback
-----Fallback Location
I set mine to D:\VC++\v16
. Where I use v140 for VS2015 and v141 for VS2017. Also set "Always Use" and "Do not warn".
Upvotes: 0
Reputation: 428
Sorry to revive a dead thread but i solved this on VS2017 by deleting the project template cache and item template cache folders in
%localappdata%\Microsoft\VisualStudio\[BUILD]
Then resetting the visual studio settings via
Tools>Import and export settings>reset all settings
Also ive heard turning off "Lightweight solution load for all projects" can help.
Upvotes: 10
Reputation: 88
I found the solution below on https://developercommunity.visualstudio.com/content/problem/260196/add-a-reference-raise-error-error-hresult-e-fail-h.html address.
It worked for me in VS 2019:
1 Open "Developer Command Prompt for VS 2017" as Admin
2 CD into "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies"
3 Run "gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll"
After a restart, it all worked well.
Upvotes: 3
Reputation: 71
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
Upvotes: 0
Reputation: 51
Root Cause: Microsoft.VisualStudio.Shell.Interop.11.0.dll is missing from GAC.
Solution: 1. Go to start menu and Open Command Prompt for Visual Studio 2. Enter command gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll 3. If in case your system unable to find this dll file then you may download it from Nuget package manager and then can provide the path of dll
All set! hit enter and you're done!
Upvotes: 2
Reputation: 31
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
Upvotes: 3
Reputation: 21
The error occurred for me after I installed the latest Windows 10 SDK. I was getting the error while building a C++ project using SDK 8.1. In Project properties, I switch to latest 10 SDK. rebuild. That worked. Changed back to 8.1. Rebuild. No error.
Upvotes: 1
Reputation: 1
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)
Upvotes: 0
Reputation: 5784
I had the same problem with a c++ project in Visual Studio 2019.
The following solution worked for me:
Upvotes: 118
Reputation: 618
I tried all of the above solutions none work for me, I found the solution here
Open ActivityLog.xml by going into
C:\Users\{UserName}\AppData\Roaming\Microsoft\VisualStudio\15.{Id}
Check if error states that
"CreateInstance failed for package
[ReferenceManagerPackage]Source: 'mscorlib' Description: Could not load type
'Microsoft.VisualStudio.Shell.Interop.' from assembly
'Microsoft.VisualStudio.Shell.Interop.11.0'
Then run this gacutil
command through VS Cmd prompt (admin mode):
Navigate to
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies
Run gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll
Upvotes: 4
Reputation: 126
I had the same issue after an upgrade from VS2013 to VS2015.
The project I was working at referenced itself. While VS2013 didn't care, VS2015 didn't like that and I got that error. After deleting the reference, the error was gone. It took me around 4 hours to find that out...
Upvotes: 2
Reputation: 41
Not sure about the exact reproduction steps for the error (HRESULT E_FAIL has been returned from a call to a COM component), but the solution for me was:
After the restart, the error was gone.
Upvotes: 3
Reputation: 1
I fixed the same issue by deleting ComponentModelCache folder
%APPDATA%/..
and press enterC:\Users\\AppData
Local\Microsoft\VisualStudio\<version>
where is 12.0 for Visual Studio 2013.From here: http://withmartin.net/how-visual-studios-component-model-cache-can-be-a-pain/
Upvotes: 0
Reputation: 1
Connection Context :- Retrieving the COM class factory for component with CLSID {632F4591-AA62-4219-8FB6-22BCF5F60090} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Upvotes: 0
Reputation: 389
My problem manifested with opening Win10 appxmanifest file (no pun intended). Simply installing Windows 10 tools and SDK (go to New->Project->Select Windows->Install Tools) fixed it.
Upvotes: 0
Reputation: 272
I wanted to add that I encountered this error when opening designer file in WinForms app. My issue was that one of the references in the project was referencing itself. Apparently this can happen as mentioned here
I removed the reference and it is working fine.
Upvotes: 7
Reputation: 380
HRESULT E_FAIL has been returned from a call to a COM component
In my case, it was because i had differents projects with same GUID in my solution. (Project was created by copy/paste)
Upvotes: 0
Reputation: 1399
I recently spent about 3 hours trying to fix this issue on my ASP.NET app running on local IIS. I had 'Override application root URL' specified and I specified the url with an ending forward slash (/) such as http://my.dev.com/
. If I saved the project options and came back in it would show the overrided root url as http://http://my.dev.com
. Once I removed the last forward slash it started to behave ok and the error went away.
Upvotes: 0
Reputation: 536
In my case, it appears that this message can be issued by Intellisense in Visual Studio 2013. The screenshot below shows the error at the bottom of VisualStudio 2013 after the first load of a customer project.
I started googling what causes this error, and decided to try deleteing the user.vxproj files as mentioned above. I found however that the project built with no issues, then after exiting and re-loading the project, I no longer received the error. So I'm assuming in my case, it was some corruption due to moving the project from the customers directory tree structure to my local development disk tree structure. The key here is that in my case, the problem was transient. I did NOTHING and the problem appeared to resolve itself. (Not generally a desirable thing as I didn't fix anything so it might come back).
Upvotes: 0
Reputation: 1394
I removed the csproj.user files and it worked for me.
In some other cases, to fix this error, I go to Web tab in the project properties and check "Use Visual Studio Development Server" and "Auto-assign Port". After that I need to rebuild the project and restart VS
Upvotes: 81
Reputation: 11
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
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
Upvotes: 1
Reputation: 611
This happens in our TFS build server some times (Gated check in). It is about workspace folder. I don't know why but workspace folder access sometimes corrupt. What I am doing to fix issue is deleting TFS build workspaces and deleting relevant workspace folders. TFS build machine then create new workspaces for itself and problem is fixed.
Tousif Ahmed's solution should work for local builds. Copy application folder to another place should do the same thing what I am doing in TFS build machine.
Upvotes: 0