I've never dealt with ActiveX controls but I wanted to add one to an an existing MFC project using VS2019. I created a dialog in the resource editor, I added the ActiveX control I wanted to play with (RDP - tried different versions), resized it. Then closed the tab, when I try to open that dialog in the resource editor I get:
---------------------------
Microsoft Visual Studio
---------------------------
The ActiveX control "Microsoft RDP Client Control (redistributable) - version 11" could not be instantiated.
---------------------------
OK
---------------------------
What's wrong and how do I fix it?
Also, what is the difference between the ones that say (redistributable) vs the ones that don't have that?
TIA!!
P.S. After that error above, if I try to open again I get:
An error occurred while initializing the frame's content
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowPaneDocumentObject.Init(Boolean initSize)
at Microsoft.VisualStudio.Platform.WindowManagement.DocumentObjectSite.InitializeDocumentObject(Object punkView)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.InitializeDocumentSite(Boolean creatingStubFrame, Boolean replacingStubView, Object punkView, Object punkData, IServiceProvider pServiceProvider, IVsUIHierarchy pUIHierarchy, UInt32 vsid)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.CreateContentPane(FrameMoniker frameMoniker, Boolean isDocument, String lpstrMkDoc, UInt32 eCreateWindowFlags, Object punkView, Object punkData, IServiceProvider pServiceProvider, IVsUIHierarchy pUIHierarchy, UInt32 vsid, Guid rguidCmdUI, ViewGroup parent, IVsWindowFrame& ppWindowFrame)
File Path: Path\To\Resource.rc
Frame GUID: 177559e0-d141-11d0-92df-00a0c9138c45
Frame mode: VSFM_Float
Error Code: 0x80004005
This will be fixed in KB900411
I've added several iTextSharp DLLs to a Sharepoint 2010 project (deployed as a WebPart).
The Web Part compiles/runs fine (I can step through my WebPart project while interacting with the web part on a page on the Sharepoint site). That is, it runs fine until code is called that actually uses itextsharp.dll. Then, the page crashes, and I get (in the log file), "The system cannot find the file specified"
Do DLLs have to be deployed to a specific place for Sharepoint to find them, or...???
UPDATE
Even after copying four itextsharp DLLs to C:\Windows\Microsoft.NET (Windows Server 2008, .NET 3.5), I get the same err msg.
For the gory details from the log file:
03/30/2015 14:49:28.43 w3wp.exe (0x0968) 0x1834 SharePoint Foundation Runtime tkau Unexpected System.IO.FileNotFoundException: Could not load file or assembly 'itextsharp, Version=5.5.5.0, Culture=neutral, PublicKeyToken=6574839201' or one of its dependencies. The system cannot find the file specified. at XMLToPDF.XMLToPDFWebPart.XMLToPDFWebPart.ConvertFromXMLToPDF(List`1 listOfListItems) at XMLToPDF.XMLToPDFWebPart.XMLToPDFWebPart.btnSave_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) ef8cece3-42f4-47d0-ab0a-ca2f0fff46e4
The link provided by user2864740 was key.
In a nutshell, this is what I did:
2-clicked Package.package
Selected the "Advanced" button
Selected the "Add" > "Add Existing Assembly" button
Verified "GlobalAssemblyCache" was selected
Using the ellipsis button affiliated with the "Source Path" edit, added each needed DLL one at a time
Saved Package.package
And: voila! Joy in Mudville, including a ticker-tape parade, a marching band featuring 76 trombones, and the whole nine yards (IOW, it worked).
I am Experiencing the following error with:
- Visual Studio 2013 Ultimate Update 1 (Same with Update 3)
- Windows 10 TP Build 9860
- Windows Store Apps Only (No error with a WPF Desktop Application).
Error Decription:
- UI XAML Designer doesn't work (see attached exception)
- Intellisense in the XAML file doesn't work (no suggestion showed up).
System.Exception
Install failed. Please contact your software vendor.
Deployment Register operation with target volume C: on Package App.aa5630c6a.a99c1.a41a2.aaba0.ac20dd792d3d9_1.0.0.0_x86_NorthAmerica_8wekyb3d8bbwe from: (C:\Users\Diego\AppData\Local\Microsoft\VisualStudio\12.0\Designer\ShadowCache\hwvetbdr.ucs\pfhjajzj.4bs\AppXManifest.xml) failed with error 0x80070002. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.
at Microsoft.Expression.HostUtility.Platform.AppContainerProcessDomainFactory.CreateDesignerProcess(String applicationPath, String clientPort, Uri hostUri, IDictionary environmentVariables, Int32& processId, Object& processData)
at Microsoft.Expression.DesignHost.Isolation.Primitives.ProcessDomainFactory.ProcessIsolationDomain..ctor(ProcessDomainFactory factory, IIsolationBoundary boundary, AppDomainSetup appDomainInfo, FrameworkName targetFramework, String identifier, String baseDirectory)
at Microsoft.Expression.DesignHost.Isolation.Primitives.ProcessDomainFactory.CreateIsolationDomain(IIsolationBoundary boundary)
at Microsoft.Expression.HostUtility.Platform.AppContainerProcessDomainFactory.CreateIsolationDomain(IIsolationBoundary boundary)
at Microsoft.Expression.DesignHost.Isolation.Primitives.IsolationBoundary.Initialize()
at Microsoft.Expression.DesignHost.Isolation.Primitives.IsolationBoundary.CreateInstance[T](Type type)
at Microsoft.Expression.DesignHost.Isolation.IsolatedObjectFactory.Initialize()
at Microsoft.VisualStudio.ExpressionHost.Services.VSIsolationService.CreateObjectFactory(IIsolationTarget isolationTarget, IObjectCatalog catalog)
at Microsoft.Expression.DesignHost.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
at Microsoft.Expression.DesignHost.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
at Microsoft.Expression.DesignHost.IsolatedDesignerService.CreateLease(IIsolationTarget isolationTarget, CancellationToken cancelToken, DesignerServiceEntry& entry)
at Microsoft.Expression.DesignHost.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)
at Microsoft.Expression.DesignHost.Isolation.IsolatedTaskScheduler.InvokeWithCulture[T](CultureInfo culture, Func`2 func, CancellationToken cancelToken)
at Microsoft.Expression.DesignHost.Isolation.IsolatedTaskScheduler.<>c__DisplayClassa`1.<StartTask>b__6()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
Uninstalling and re-installing didn't fix it.
Has anyone experienced it ?
Edit:
Also property tab is blank for every XAML Control
Windows 10 is currently a technical preview and is not meant for you to develop up on, you need o wait for the Windows 10 Developer Preview so that you can start coding on Windows 10 (which will probably come out near the BUILD 2015 event in my opinion).
As they say here: http://technet.microsoft.com/en-US/windows/dn798751.aspx?ocid=wc-mscom-wol
"Windows 10 Technical Preview for Enterprise is an early look at some of the features and functionality in store for Windows 10, the next version of the Windows client operating system. This page offers resources to help you explore Technical Preview for Enterprise, assess the compatibility of your applications, and test the new in-place upgrade process."
From what i understand from this, it is mainly for you to test your apps and company apps on the OS to see if your company will be able to migrate on this or not and not for your to start coding.
Good Luck!
EDIT:
Went you look at the TechNet forum: https://social.technet.microsoft.com/Forums/en-US/home?category=WinPreview2014
you can see that they are mainly looking a bugs with the OS and not about how to develop apps.
I'm getting an error message every time I start Visual Studio. Since I'm also seeing some unexplained behavior in my project, I'd like to resolve this issue.
Error Message
An exception has been encountered. This may be caused by an extension.
You can get more information by examining the file 'C:\Users\Jonathan\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml'.
When I look at the log file, I find two exceptions:
Error 1
Exception Type : System.Windows.Markup.XamlParseException
Exception Message : Provide value on 'System.Windows.StaticResourceExtension' threw an exception.
Exception Stack Trace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at SquaredInfinity.VSCommands.UI.Views.DefaultAlertView.InitializeComponent()
at SquaredInfinity.VSCommands.Foundation.Services.VSCUIService.GetDefaultAlertViewModel(String alertMessage, String alertDialogTitle)
at SquaredInfinity.Foundation.Presentation.Services.UIService.GetDefaultAlertViewModel(String alertMessage)
at SquaredInfinity.Foundation.Presentation.Services.UIService.ShowAlert(String message)
at SquaredInfinity.VSCommands.VSCommandsPackage.Initialize()
Exception Data : [EmptyOrNull]
Inner Exception:
Exception Type : System.Exception
Exception Message : Cannot find resource named 'VSC.Button'. Resource names are case sensitive.
Exception Stack Trace: at System.Windows.StaticResourceExtension.ProvideValueInternal(IServiceProvider serviceProvider, Boolean allowDeferredReference)
at System.Windows.StaticResourceExtension.ProvideValue(IServiceProvider serviceProvider)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
Exception Data : [EmptyOrNull]
Error 2
System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) The current type, SquaredInfinity.Foundation.Configuration.Services.IConfigurationService, is an interface and cannot be constructed. Are you missing a type mapping?
Resulting in: Resolution of the dependency failed, type = "SquaredInfinity.Foundation.Configuration.Services.IConfigurationService", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, SquaredInfinity.Foundation.Configuration.Services.IConfigurationService, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving SquaredInfinity.Foundation.Configuration.Services.IConfigurationService,(none)
Resulting in: An exception occurred while trying to create an instance of type '#Btb.#Rtb'.
Resulting in: Cannot activate part '#Btb.#Rtb'.
Element: #Btb.#Rtb --> #Btb.#Rtb
Resulting in: Cannot get export '#Btb.#Rtb (ContractName="Microsoft.VisualStudio.Text.Classification.IClassifierProvider")' from part '#Btb.#Rtb'.
Element: #Btb.#Rtb (ContractName="Microsoft.VisualStudio.Text.Classification.IClassifierProvider") --> #Btb.#Rtb
at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart part, ExportDefinition export, Boolean isSharedPart)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()
at System.ComponentModel.Composition.Primitives.Export.get_Value()
at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)
at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass4`2.<CreateStronglyTypedLazyOfTM>b__1()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InvokeMatchingFactories[TExtensionInstance,TExtensionFactory,TMetadataView](IEnumerable`1 lazyFactories, Func`2 getter, IContentType dataContentType, Object errorSource)
How do I interpret this so that I can figure out the error?
It seems there is something wrong with the VSCommands extension or another plugin. You can try to disable all extensions, restart Visual Studio and re-enable them; sometimes it resolves such issue.
Another thing you can try, is to run Visual Studio as administrator, because this error can occur if there are not sufficient permissions to access some resources (it was a bug in older releases of Visual Studio).
Your last painful resort will be a clean re-installation.
Just reinstall latest Web Essentials 5/5/2013. It resolves the problem. No need to uninstall or disable anything, just run setup again and you are done.
http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6
Fixed by deleting the following folder:
C:\Users{username}\AppData\Local\Microsoft\VisualStudio{version-number}\ComponentModelCache
This error starts after installing Visual Studio 2012 Update 2. Apparently the Web Tools and Web Essentials 2012 extensions have a conflict -- they both try to register some of the same components, which generates this exception.
Additionally, it appears the automatic update notification for one or both of these extensions is broken when VS 2012 Update 2 is installed, because though the extensions have been updated to resolve the conflict, you aren't notified that an update exists.
The solution is to remove both extensions, then reinstall them.
For more information about this, see http://madskristensen.net/post/web-tools-20122-and-web-essentials.
I was getting this same error. I noticed that the NuGet Package Manager extension had an update. After installing this update, the error went away.
Make sure all available updates are applied. To check if there are any updates available open Tools > Extensions and Updates. In the "Extensions and Updates" dialog, expand the "Updates" node in the left pane. Install any updates that may be available and restart Visual Studio 2012.
For all people having this problem:
Open Visual Studio 2012, but don't load any solutions / projects
Open Extensions and Updates from the Tools menu
Disable Web Essentials 2012
Delete the .suo file for your solution
Open the solution in Visual Studio
See that it loads and Visual Studio doesn't crash
Enable Web Essentials 2012
Restart Visual Studio 2012 and reload your solution.
Happy times!
Source
All you need to resolve the above stated issue is to delete the *.suo file for the project and Visual Studio. I had the same issue.
I was also getting the same error:
An exception has been encountered. This may be caused by an extension.
You can get more information by examining the file 'C:\Users\ . . .
\VisualStudio\11.0\ActivityLog.xml'
Reason:
I had uninstalled some of the SQL files from the control panel. Only after that did I start to get this error, but I was not sure which service I had uninstalled.
Solution:
I downloaded the SDK for Visual Studio 2012 and installed/restarted Visual Studio, then it worked fine.
In Silverlight 4 app; what does this error mean?:
"Error HRESULT E_FAIL has been returned from a call to a COM component."
It's a very generic error. The VS debugger doesn't point to the exact location of the error when debugging.
This is kind of an old question, but I figured I'd give my answer since I found this thread by Googling for the exact same problem.
In my case, I'd copied some sample XAML from the web to get started with Silverlight Toolkit 4. That sample XAML contained a simple button with a click event handler that didn't relate to any handler that actually existed in my code behind. I didn't notice this simple problem at first, because the compiler didn't give me an error message, I just saw the "Error HRESULT E_FAIL has been returned from a call to a COM component" message above at runtime. It was only when I isolated my sample XAML by copying it into a brand new Silverlight application without any other content that the real underlying problem was revealed at compile-time.
So, if you've got the same error message at runtime, my advice is to check your XAML carefully for any errors that you had expected should have been picked up at compile time, but which for some reason ended up as the runtime error noted above. In order to debug, you can do what I did and isolate the code that's causing the error in a standalone Silverlight app with no other content, and see if like me you get a more helpful error message to guide you.
HTH.
There are many solutions out there but this is the only solution that worked several times for me.It has been tried on VS2012 VS2013 and VS2015, I find it working equally good for all.Just follow steps bellow to fix this issue
Step 1 : Close Visual Studio
Step 2 : Delete *.csproj.user and *.suo files
Step 3 : Reopen VS, and try to run project again in debug mode.
NOTE : This situation occurs when multiple users working on same
project with different VS versions .suo file is not supported
for round-tripping between the two VS versions.It contains information
about what settings current user has selected for his/hers VS working
environment.
In my situation:
I create a
class MyControl : ContentControl {
}
By default, the class is not public and XAML cannot load it and throw exception
Error HRESULT E_FAIL has been returned from a call to a COM component
Just change the scope of class to public and error disappear.
Hope this help.
PS. Microsoft should provide more on information than just throw a mystery error message without any stack trace.
I also had this error and I found that this problem is related to not have added all requiered assemblies to your project. In my case I was using a UserControl with a depency with the Silverlight Toolkit and I havent added this reference.
I just added the reference and everything solved :)
I had this error using the current SL4 Telerik controls. A similar issue has been reported here with a solution ... of sorts. The problem seems to be with the way Expression Blend manages the cache of controls.
Here's one way to generate this error, which I stumbled upon today. We have the following button in XAML:
<Button x:Name="button" Click="Button_Click" Content="Click me" />
The event handler that handles the button's Click event is as follows:
private void Button_Click(object sender, RoutedEventArgs e)
{
button.Margin = new Thickness(0, double.NaN, 0, 0);
}
When I click on the button I get the aforementioned error. The same error arises if I replace NaN with PositiveInfinity or NegativeInfinity.
Interestingly, I get a different error message if the first parameter of the Thickness constructor contains the NaN instead of the second.
I had this error from problems with XAML. The strange thing was that I had missing resources used by Style and Margin attributes - which means the app runs fine, and even resharper only reports a 'hint'.
Once I cleared up those problems my "Error HRESULT E_FAIL has been returned from a call to a COM component." disappeared. As others have said though, this is a vague error, very difficult to debug. In this case I have inherited a large project with 100's of VS and ReSharper messages with varying severity - missing StaticResource on Style attributes were not the first place I checked!
I had this error in my xaml page and there were no syntax errors. Cleaning and re-building the project solved my issue. fyi...
The IIS App Pool has to run as an account that has query access to the Team Foundation Server. This fixes the problem for me.
Most of the reason of this problem related dependency propertied on component design.
You just face off this problem on design.
Soulution is easy but takes time :) Clean project and rebuild all. When you enter the desing again you should see everything is fine!
I hope this helps!
If you see this exception recently, please try to re-install silverlight sdk4.
This is a security and permissions issue. Look into the IIS and make sure Integrated Security is ON. Then set Application Protection level to Medium (If it is high then this might be the result). Then check your Web.Config file. Make sure impersonation is off.
This should help.
I had this problem while I was encoding Live video and audio (using Microsoft Expression) and the next piece of code throws the exception randomly:
// Set bitrate
liveJob.OutputFormat.VideoProfile.Bitrate = new ConstantBitrate(2500);
// Set Video size
liveJob.OutputFormat.VideoProfile.Size = new Size(320,240);
until i've figured out that the second line throws the exception while the first one is still running in another thread !
and of course, it was my fault - i've called the method in code, and it was also been called by Click event...
I had this exception and went nuts. I would advice you check if you had recently installed a component that had possible conflicting namespace items. In my case I installed the windows phone tool-kit which had items that were similarly named with the stock tool kit on windows phone.
Asap I uninstalled this from the Nuget package manager, all was back to normal.
Here is what FINALLY fixed this problem for us when trying to use MICROSOFT.TEAMFOUNDATION library when querying Team Foundation Server:
Team Foundation Explorer has to be installed with the currect version that is referenced in the application.
MSDTC – Configuration. (See DTC config below)
IIS App Pool has to run as an account that has query access to the Team Foundation Server
IIS App Pool has to run as an account that has COM access on IIS Server (We have a dedicated server for this so we made the identity user an administer on the local server).
Firewall has to be off or configured to allow COM access for DTC service.
DTC config ----
Click Start, click Run, type dcomcnfg and then click OK to open Component Services.
In the console tree, click to expand Component Services, click to expand Computers, click to expand My Computer, and click to expand Distributed Transaction Coordinator.
Right click Local DTC, and click Properties to display the Local DTC Properties dialog box.
Click the Security tab.
In the Security Settings section, click Network DTC Access.
In the Client and Administration section, select Allow Remote Clients and Allow Remote Administration.
In the Transaction Manager Communication section, select Allow Inbound and Allow Outbound.
In the Transaction Manager Communication section, select Mutual Authentication Required (if all remote machines are running Windows Server 2003 SP1 or Windows XP SP2 or higher), select Incoming Caller Authentication Required (if running MSDTC in a cluster), or select No Authentication Required if some of the remote machines are pre-Windows Server 2003 SP1 or pre-Windows XP SP2. No Authentication Required is the recommended selection.
I hope this helps.
My problem was a missing Style. I had overridden a control template with a custom brush like so:
<Style x:Key="MyCustomStyle" TargetType="Thumb">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Thumb">
....
<TextBlock Foreground="{StaticResource MyCustomBrush}"
and was missing my definition of MyCustomBrush, like so:
<SolidColorBrush x:Key="MyCustomBrush" Color="#FFAC0909"/>
and then BOOM, app didn't startup and I got that COM error message.
Well, I was almost going to eat my computer..
At last, I find out the problem is that I MAYBE BY ACCIDENT removed one parameter of one Margin setting of an Image object in the XAML page, orz..
Margin="0,-20,0"
which should be
Margin="0,-20,0,0"
Obviously I didn't realized I have ever modified anything of the XAML, so I have been troubleshooting the code behind for "a little while"..
Fortunately, I found this post and rechecked everything include the XAML page.. that was ... something...
For me, I narrowed it down to a SplitButton control that I downloaded off CodePlex ages ago. I had upgraded the solution from Silverlight 4 to Silverlight 5 and got slammed with this error. I was able to narrow it down by commenting out the XAML to all controls then uncommented it back in one by one until the error appreared again:
System.Reflection.TargetInvocationException was unhandled by user code
Message=Exception has been thrown by the target of an invocation.
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at Homexaml_3.BindingOperation(Object BindingState, Int32 , Action )
InnerException:
Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
StackTrace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
What fixed it was manually removing the outdated references System.Windows.Control and System.Windows.Controls.Toolkit then re-added them from the Silverlight 5 SDK folder.
Hope it helps someone (and helps me!) if it happens again a few months down the road.
I received this error recently in VS 2013 for a Silverlight 5 project. None of the above worked for me. Oddly enough, it was a threading problem (normally I am used to an exception that explains this if I am trying to create UIElements on a background thread by mistake).
Wrapping my code that adds UIElements to the MainPage with Dispatcher.BeginInvoke solved the problem:
Dispatcher.BeginInvoke(() =>
{
// your code
});
Most of the times its difficult to see where exactly the problem is located especially in XAML.
Another way to find out where its failing is to perform the following steps
Copy the exception it shows in the output window of Visual Studio. example. System.Reflection.TargetInvocationException
Click on Debug -> Exceptions. It shows up the exception list.
Click on the "Add.." button.
Paste the exception copied in the step 1 in the text box. Select "Common Language Runtime exceptions" in the drop down list.
Click on "Ok" button. The selected exception will be highlighted. Make sure you check the checkbox against the exception. Click on "Ok" button again to close the dialog.
Now run the application in debug mode. The application breaks when the exception occurs. Sometimes in the assembler mode as well.
At this point in time you have two options,
Click on the View details of the exception screen shown. Dig into
the inner exceptions until you get a clue from where its
originating.
View the call stack to see which code of line of your is causing
this exception. This will provide clues to resolve the issue.
For me, this was a XAML parsing error. In a data template, I had an extra S between two tags (probably because I pressed S instead of CTRL+S). For example...
<DataTemplate>
<Border/>s
</DataTemplate>
So, I would suggest you look for poorly formatted XML in the view that causes this exception when displayed.
In my case it was, when I tried to import database into the SSDT project, but this database already was in project, but was empty. I've just updated my project with Tools -> SQL server -> New schema comparsion. Source - database, target - project. Compare - update.
Hope it helps to someone
This error seems to be a 'catch-all' for errors that otherwise are not given a specific definition or tracing, especially those having to do with relatively external Xaml code.
In my particular case, there seemed to be an issue with the namespaces. My UserControl is in its own namespace (creatively named "UserControls"). My Pages are in their own namespace ("Pages"). I wanted to reference an enum definition in the Pages namespace from within my UserControl, so I simply added a using statement: using MySolution.Pages;. Trivial enough, and I didn't want to believe that this was the problem. But when I removed that using statement and simply created the enum in my UserControls namespace, voila, no more HRESULT error and also, as an added bonus, my dependency properties defined in the UserControl, which otherwise were mysteriously not showing up in the Xaml intellisense, suddenly were there and ready to use.
I suspect that underlying cause for this in my case was some sort of circular reference issue. And since there was no more specific error available to relate that information to me, it simply got shuffled into this HRESULT E_FAIL Com error.
I fixed this error by deleting the XAML file and add a new one from add new item. Then I pasted the XAML codes that was there in the old file.
This is an old question but in my case, none of the above solutions worked. I was trying to update the NuGet packages in Visual Studio 2017 but I was getting the following Exception.
update-package : Failed to add reference to 'System.Web.Razor'.
Error HRESULT E_FAIL has been returned from a call to a COM component.
In fact, other NuGet commands like restore-package were failing with similar exception message.
I discovered a few assemblies were missing under the packages directory so I deleted the packages directory and returned back to the Visual Studio 2017. When I opened the solution it asked me to restore the packages and after that, I was able to update the packages.
NOTE: Take a backup of package directory before deleting it.
I encountered this same error after installing VS2019 and 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".
If anyone facing this issue, while adding reference in console/windows applications, follow the below steps
Open "Developer Command Prompt for VS 2017" as Admin
CD into "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies"
Run "gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll"
Restart Visualstudio
Reference - https://developercommunity.visualstudio.com/t/add-a-reference-raise-error-error-hresult-e-fail-h/260196