简体   繁体   中英

First-chance COMException thrown at application startup but cannot break to find out where/why it's happening

Using: Visual Studio 2012, .NET Framework 4, Windows 7 x64

Sometimes, upon starting my application in debug mode, I see the following line in the Output window:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualStudio.HostingProcess.Utilities.dll

This happens approximately once in every 10 startups and appears to be random (no code is changed, I can just Start, Stop, Start, Stop, etc. until I see the error in Output).

I would like to know what is causing this first-chance exception. I have the option " Tools->Options->Debugging->General->Enable Just My Code " disabled and I have enabled the " Debug->Exceptions...->Common Language Runtime Exceptions->System.Runtime.InteropServices->System.Runtime.InteropServices.COMException " option (see screenshot below) in order to break upon getting the exception, but Visual Studio does not break so I don't know where the issue is.

I've tried placing random breakpoints in my code but it seems that whenever I actually have a breakpoint set then the exception doesn't occur.

Sounds like the error is occurring within Visual Studio's attempt to host the process. First Chance exceptions can be caught and handled by applications without further problem. The Output Window is just displaying it has happened. I wouldn't worry about it. Maybe an update to Visual Studio in the future will resolve this.

I would not expect it to occur at Runtime outside of the Visual Studio host process.

I know this post is quite old but I wanted to share my solution in case it would help anyone else.

I started having this problem after updating to Visual Studio 2012 Update 1. Only my issue is that is was appearing every time. I could create a new project and just run a blank form and the message would appear. It would get slower with each run.

While trying to find help online I stumbled upon a site talking about running a VS 2012 Command Prompt in Administrator mode (in the tools folder of your Visual Studio 2012 Start Menu)

Unfortunately, I can't remember if I actually performed the ResetSkipPkgs so check for the error before running the second option.

    devenv /Resetsettings
    devenv /ResetSkipPkgs

This resolved my issue. (of course, you will lose any settings you had made to your IDE)

Just had same issue using VS 2012; this started yesterday for no apparent reason. No environment changes that I'm aware of at least none that I made and no other users on this machine.

So created simple Hello-World Console app and sure enough, would not run and received same error. Could not step into any code. Targeted framework was 4.5, default for VS 2012, so changed to 4.0 and everything magically worked.

Then changed back to 4.5 and magic continued. Did same with all projects in my solution. Everything seems happy again.

Wish I had backed up my VS settings for MS... If it happens again, I'll do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM