3

使用:Visual Studio 2012、.NET Framework 4、Windows 7 x64

有时,在调试模式下启动我的应用程序时,我会在输出窗口中看到以下行:

Microsoft.VisualStudio.HostingProcess.Utilities.dll 中出现了“System.Runtime.InteropServices.COMException”类型的第一次机会异常

这大约在每 10 次启动中发生一次,并且似乎是随机的(没有更改代码,我可以启动、停止、启动、停止等,直到我在输出中看到错误)。

我想知道是什么导致了这个第一次机会异常。我禁用了“工具->选项->调试->常规->启用我的代码”选项,并启用了“调试->异常...->通用语言运行时异常->System.Runtime.InteropServices- >System.Runtime.InteropServices.COMException ”选项(见下面的截图),以便在收到异常时中断,但 Visual Studio 没有中断,所以我不知道问题出在哪里。

我尝试在我的代码中放置随机断点,但似乎每当我实际设置了断点时,异常就不会发生。

4

3 回答 3

3

听起来错误是在 Visual Studio 尝试托管进程时发生的。应用程序可以捕获和处理 First Chance 异常,而不会出现进一步的问题。输出窗口只是显示它已经发生。我不会担心的。也许将来对 Visual Studio 的更新将解决此问题。

我不希望它发生在 Visual Studio 主机进程之外的运行时。

于 2012-10-11T21:14:30.517 回答
2

我知道这篇文章已经很老了,但我想分享我的解决方案,以防它对其他人有所帮助。

更新到 Visual Studio 2012 Update 1 后,我开始遇到这个问题。只有我的问题是每次都出现。我可以创建一个新项目并运行一个空白表单,然后就会出现消息。每次运行都会变慢。

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)

于 2013-02-27T17:01:45.667 回答
0

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.

于 2014-10-20T19:40:58.090 回答