如何避免 System.Runtime.InteropServices.COMException? [英] How to avoid a System.Runtime.InteropServices.COMException?

查看:36
本文介绍了如何避免 System.Runtime.InteropServices.COMException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Microsoft Surface 项目中,我总是遇到很多以下异常:

In my Microsoft Surface project, I always get a lot of the following exceptions:

'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_32mscorlib2.0.0.0__b77a5c561934e089mscorlib.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.VisualStudio.HostingProcess.Utilities10.0.0.0__b03f5f7f11d50a3aMicrosoft.VisualStudio.HostingProcess.Utilities.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILSystem.Windows.Forms2.0.0.0__b77a5c561934e089System.Windows.Forms.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILSystem2.0.0.0__b77a5c561934e089System.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILSystem.Drawing2.0.0.0__b03f5f7f11d50a3aSystem.Drawing.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.VisualStudio.HostingProcess.Utilities.Sync10.0.0.0__b03f5f7f11d50a3aMicrosoft.VisualStudio.HostingProcess.Utilities.Sync.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.VisualStudio.Debugger.Runtime10.0.0.0__b03f5f7f11d50a3aMicrosoft.VisualStudio.Debugger.Runtime.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:UsersRoflcoptrDocumentsVisual Studio 2008ProjectsMuReSeMuReSeinDebugMuReSe.vshost.exe'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILSystem.Core3.5.0.0__b77a5c561934e089System.Core.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILSystem.Xml.Linq3.5.0.0__b77a5c561934e089System.Xml.Linq.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILSystem.Data.DataSetExtensions3.5.0.0__b77a5c561934e089System.Data.DataSetExtensions.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_32System.Data2.0.0.0__b77a5c561934e089System.Data.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILSystem.Xml2.0.0.0__b77a5c561934e089System.Xml.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILWindowsBase3.0.0.0__31bf3856ad364e35WindowsBase.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_32PresentationCore3.0.0.0__31bf3856ad364e35PresentationCore.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILPresentationFramework3.0.0.0__31bf3856ad364e35PresentationFramework.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.Surface1.0.0.0__31bf3856ad364e35Microsoft.Surface.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.Surface.Presentation1.0.0.0__31bf3856ad364e35Microsoft.Surface.Presentation.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.Surface.Presentation.Generic1.0.0.0__31bf3856ad364e35Microsoft.Surface.Presentation.Generic.dll'
The thread 'vshost.NotifyLoad' (0x1504) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x131c) has exited with code 0 (0x0).
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:UsersRoflcoptrDocumentsVisual Studio 2008ProjectsMuReSeMuReSeinDebugMuReSe.exe', Symbols loaded.
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILSystem.Configuration2.0.0.0__b03f5f7f11d50a3aSystem.Configuration.dll'
Step into: Stepping over method without symbols 'MuReSe.App.App'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.Surface.Shell.ShellApi1.0.0.0__31bf3856ad364e35Microsoft.Surface.Shell.ShellApi.dll'
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.Surface.Common1.0.0.0__31bf3856ad364e35Microsoft.Surface.Common.dll'
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Shell.ShellApi.dll
A first chance exception of type 'Microsoft.Surface.Common.ProcessCommunicationException' occurred in Microsoft.Surface.Shell.ShellApi.dll
A first chance exception of type 'System.Threading.WaitHandleCannotBeOpenedException' occurred in mscorlib.dll
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.Surface.Core1.0.0.0__31bf3856ad364e35Microsoft.Surface.Core.dll'
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Surface.Core.dll

最后一个异常一直抛出,直到我停止程序.我已经注释掉了我的所有代码,并且除了已经内置的代码之外我什么都没有运行应用程序,但同样发生了.

The last Exception is thrown all the time until I stop the program. I already commented out all of my code, and I ran the application with nothing other than the already built in code, but the same happens.

我该如何纠正?我只找到了这个参考:

How can I correct that? I only found this reference:

http://www.mobydisk.com/softdev/techinfo/dotnetexceptions.html

上面写着:

抛出的异常无法识别的 HRESULT 从返回一个 COM 方法调用.

The exception that is thrown when an unrecognized HRESULT is returned from a COM method call.

但我不知道这是什么意思....

But I don't know what this means....

====编辑====

我按照下面答案中的建议来调试异常.这是详细的报告:

I followed the suggestion in the answer below to debug the exception. This is the detailed report:

System.Runtime.InteropServices.COMException occurred
  Message=Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  Source=Microsoft.Surface.Shell.ShellApi
  ErrorCode=-2147221164
  StackTrace:
       at Microsoft.Surface.Shell.NativeMethods.CoCreateInstance(Guid rclsid, Object pUnkOuter, CLSCTX dwClsContext, Guid riid)
  InnerException: 

调试器在构造函数调用处停止:

And the debuger stopped at the constructor call:

 public MainWindow()
        {
            InitializeComponent();

            // Add handlers for Application activation events
            AddActivationHandlers();

           // AssemblyParser parser = new AssemblyParser();
            //parser.parse();

           // DirSearch(@"C:UsersRoflcoptrDocumentsVisual Studio 2008ProjectsTestClass.dll");
        }

我在构造函数的开头就停了下来:

I stopped right at the start of the constructor:

public MainWindow()

推荐答案

您的代码(或您调用的某些代码)正在调用返回未知值的 COM 方法.如果你能找到,那么你就成功了一半.

Your code (or some code called by you) is making a call to a COM method which is returning an unknown value. If you can find that then you're half way there.

您可以尝试在抛出异常时中断.转至 Debug > Exceptions... 并使用 Find... 选项找到 System.Runtime.InteropServices.COMException.勾选抛出时中断的选项,然后调试您的应用程序.

You could try breaking when the exception is thrown. Go to Debug > Exceptions... and use the Find... option to locate System.Runtime.InteropServices.COMException. Tick the option to break when it's thrown and then debug your application.

希望它会在有意义的地方中断,您将能够追溯并找到错误的根源.

Hopefully it will break somewhere meaningful and you'll be able to trace back and find the source of the error.

这篇关于如何避免 System.Runtime.InteropServices.COMException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆