I'm following along with the Contoso University and I'm running into the HP Computer Platform issue mentioned in this SO question about the scaffolding creation error saying deps.json does not exists in a certain folder.
I'm running Windows 7 Professional and using Visual Studio 2017 Community.
I have changed my Environment Variable, Platform, from BPC to nothing by using set Platform= in command prompt.
Still I get an error when I try to Right Click on the Controllers folder > Add > New Scaffolding Item... > MVC Controller with views, Using Entity Framework > Fill out the form by picking a Model class and Data context class > Add >
Error
There was an error running the selected code generator:
'The specified deps.json [C:\...\bin\BPC\Debug\netcoreapp1.1\ContosoUniversity.deps.json] does not exists'
I have tried cleaning cleaning the solution, restarting Visual Studio 2017, and rebooting my computer to no avail.
Not sure what else I should do to prevent this error. Any suggestions? I feel like copying the files into the BPC folder is a workaround, but not the best solution.
Edit 1
I noticed that the Environment Variable, Platform, got reset to BPC, so I deleted it and rebooted again. Didn't come back.
Now when I try to create the scaffold I get this error:
Error
There was an error running the selected code generator:
'Value cannot be null.
Parameter name: connectionString
at
Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b_6_0()
at
Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at
Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)'
Edit 2
Setting the Platform variable back to BCP manually brings back the original error.
Copying and pasting all files from ...\ContosoUniversity\bin\Debug\netcoreapp1.1\ to ...\ContosoUniversity\bin\BCP\Debug\netcoreapp1.1\ gets me past that error, but the error from Edit 1 comes back.
Seems I have two separate problems.
Turns out I made a typo in appsettings.json
I had "ConnectionString" instead of "ConnectionStrings" with an 's'
That was causing my Value cannot be null. Parameter name: connectionString error
So, to solve my original problem, follow these steps for Windows 7. (10 shouldn't be much different):
Windows key > Right click on Computer > Properties > Advanced system settings > Environment Variables... > Under System variables find Platform > Highlight Platform > Delete > OK
make sure .json file exists in path specified. and let me know about that what you find.
When I open WebMatrix it works without problem and shows the start page.
When I click 'My sites' and choose my site or choose My site by click 'Open'=> My site or create new site (and choose the site type: Empty, App Gallery or Template Gallery) WebMatrix crashes. Note: It crashes when it needs to show the site pages.
I tried to re-install WebMatrix but that didn't help. I also tried to change the Workspace(by clicking 'Options' on the start page).
When it crashes, I get the message 'Windows is looking for a solution to the problem.' (My computer isn't in English so that might not exactly be the words) and then I am asked if I want to close/debug the program. I click 'Debug' and choose Visual Studio. I don't know how to debug a program, but I tried and it says to me that:
System.NullReferenceException was unhandled
Message: An unhandled exception of type 'System.NullReferenceException' occurred in Microsoft.WebMatrix.Core.dll
Additional information: Object reference not set to an instance of an object [-translated].
I have searched on the internet and here and I didn't find any solution to my problem.
Actual Answer
This bug is in the market for a time now. I have seen similar issue on another forum too, where the user was facing the same issue and same thing he tried but all in vain.
I think you need to wait for the next Update for your System, or try removing each and every component that WebMatrix installed, that means all the .NET Frameworks (4th version), Sql Dependencies Sql Server Ce, and all other files that were shipped along with WebMatrix to your computer. Remove them, and start the installing process once again freshly.
If nothing does the job, please uninstall WebMatrix 3 and install WebMatrix 2: Click here for link. I know it is awkward to go back a version, but you'll have to. Secondly you can mention this bug on their support/suggestion page. They would fix it.
http://webmatrix.uservoice.com/
I hope that would help you. And you'd be back in developing the apps :-)
Just for information
Secondly, do you understand what is meant by debug? Debugging is a method or process to remove the bugs from a software or an application etc. When you chose Visual Studio, it provided you or not provided you with the WebMatrix source code, I am not sure I never tried it. And you tried out debugging it. The exception is gave you, was a message saying that the parameter you're passing onto the next stage is a null. Which means it doesn't even exist and thus the value or the method cannot be executed and it breaks.
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