2010-11-25 8 views
25

En mi proyecto de Microsoft Surface, siempre me dan una gran cantidad de las siguientes excepciones:Cómo evitar una excepción System.Runtime.InteropServices.COM?

'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Users\Roflcoptr\Documents\Visual Studio 2008\Projects\MuReSe\MuReSe\bin\Debug\MuReSe.vshost.exe' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Xml.Linq\3.5.0.0__b77a5c561934e089\System.Xml.Linq.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Data.DataSetExtensions\3.5.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\WindowsBase\3.0.0.0__31bf3856ad364e35\WindowsBase.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_32\PresentationCore\3.0.0.0__31bf3856ad364e35\PresentationCore.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\PresentationFramework\3.0.0.0__31bf3856ad364e35\PresentationFramework.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.Surface\1.0.0.0__31bf3856ad364e35\Microsoft.Surface.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.Surface.Presentation\1.0.0.0__31bf3856ad364e35\Microsoft.Surface.Presentation.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.Surface.Presentation.Generic\1.0.0.0__31bf3856ad364e35\Microsoft.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:\Users\Roflcoptr\Documents\Visual Studio 2008\Projects\MuReSe\MuReSe\bin\Debug\MuReSe.exe', Symbols loaded. 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll' 
Step into: Stepping over method without symbols 'MuReSe.App.App' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.Surface.Shell.ShellApi\1.0.0.0__31bf3856ad364e35\Microsoft.Surface.Shell.ShellApi.dll' 
'MuReSe.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.Surface.Common\1.0.0.0__31bf3856ad364e35\Microsoft.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:\Windows\assembly\GAC_MSIL\Microsoft.Surface.Core\1.0.0.0__31bf3856ad364e35\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.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 

La última excepción se produce todo el tiempo hasta que deje el programa. Ya comenté todo mi código, y ejecuté la aplicación con nada más que el código ya incorporado, pero sucede lo mismo.

¿Cómo puedo corregir eso? Sólo he encontrado esta referencia:

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

Allí se dice:

La excepción que se produce cuando un HRESULT no reconocido se volvió de una llamada al método COM.

Pero no sé lo que esto significa ....

==== ==== EDITAR

que siguieron la sugerencia en la respuesta a continuación para depurar la excepción. Este es el informe detallado:

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: 

Y el debuger detuvo en la llamada al constructor:

public MainWindow() 
     { 
      InitializeComponent(); 

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

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

      // DirSearch(@"C:\Users\Roflcoptr\Documents\Visual Studio 2008\Projects\TestClass.dll\"); 
     } 

Dejé justo al comienzo del constructor:

public MainWindow() 
+1

Por cierto, asegúrese de que todo el código hace referencia a la misma arquitectura. –

Respuesta

32

Su código (o algún código llamado por usted) realiza una llamada a un método COM que devuelve un valor desconocido. Si puedes encontrar eso, entonces estás a mitad de camino.

Puede intentar romper cuando se lanza la excepción. Vaya a Depurar> Excepciones ... y use la opción Buscar ... para ubicar System.Runtime.InteropServices.COMException. Marque la opción para romper cuando se lanza y luego depurar su aplicación.

Esperemos que se rompa en algún lugar significativo y podrá rastrear hacia atrás y encontrar el origen del error.

+0

Ok, gracias. Eso es realmente extraño, ya que probé esto comentando todo mi código. Y sin embargo, esto está sucediendo. Y otra cosa: creo que tiene que ser una biblioteca de terceros que estoy usando, entonces, ¿cómo puedo resolver el problema si está ubicado allí? ¿Atrapar la excepción? – RoflcoptrException

+0

@Roflcoptr: si está en el código de terceros, todo lo que puede hacer es tomarlo o dejarlo y dejarlo no es realmente una opción. Si puede reducirlo a una llamada específica, informe al desarrollador de terceros. – ChrisF

+0

¡Gracias! Seguí tu sugerencia y depuré mi proyecto. Sigo siendo muy curioso ya que está arrojado al consturctor si no hubiera cambiado nada ... – RoflcoptrException

23

Encontré System.Runtime.InteropServices.COMException al abrir una solución de proyecto. A veces el usuario no tiene suficientes privilegios para ejecutar algunos métodos COM. Ejecuté Visual Studio como administrador y la excepción desapareció.

+5

Tuve el mismo y sí, el truco es ejecutar VS como administrador. ¡Gracias por compartir, me has ahorrado mucho tiempo! –

+3

Lo que dijo @ Jean-François pero desafortunadamente. ¡Me llevó tanto tiempo hasta que decidí buscar el error en google! jaja. ¡Gracias! – maxisme

+0

Esto también ocurre cuando cambia sus proyectos de .net v.3.5 a 4.5, por ejemplo. No es que el cambio en sí mismo sea erróneo, pero podría haber condiciones conflictivas entre las versiones de frameworks, independientemente de iniciar VS como administrador o no – netfed

Cuestiones relacionadas