Share via


Unable to cast COM object of type 'System.__ComObject' to interface type

While launching Visual Studio 2012/2010 IDE, you might receive the below error message or VS IDE may just crash without any error message. I launched the devenv.exe in the debugger (https://msdn.microsoft.com/en-us/windows/hardware/gg463009) and took a crash dump (https://support.microsoft.com/kb/286350). You can also run the following command: cscript adplus.vbs -crash –sc "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"

After debugging I found the below Call Stack and exception:

0:012> !pe
Exception object: 0ded29fc
Exception type:   System.InvalidCastException
Message:          Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.OLE.Interop.IServiceProvider'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6D5140C1-7436-11CE-8034-00AA006009FA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
InnerException:   <none>
StackTrace (generated):
    SP       IP       Function
    00000000 00000001 mscorlib_ni!System.StubHelpers.StubHelpers.GetCOMIPFromRCW(System.Object, IntPtr, IntPtr ByRef, Boolean ByRef)+0x2
    00000000 00000001 UNKNOWN!Microsoft.VisualStudio.OLE.Interop.IServiceProvider.QueryService(System.Guid ByRef, System.Guid ByRef, IntPtr ByRef)+0x2
    0B69A954 0F43C2D2 Microsoft_VisualStudio_Shell_11_0_ni!Microsoft.VisualStudio.Shell.ServiceProvider+<>c__DisplayClass1.<QueryService>b__0()+0x122
    0B69A994 0F43C0E4 Microsoft_VisualStudio_Shell_11_0_ni!Microsoft.VisualStudio.ErrorHandler.CallWithCOMConvention(System.Func`1<Int32>, Boolean)+0x34

StackTraceString: <none>
HResult: 80004002

0:012> !do 0ded29fc
Name:        System.InvalidCastException
MethodTable: 529b0670
EEClass:     52627fd0
CCW:         0a86e060
Size:        84(0x54) bytes
File:        C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
529bafb0  4000002        4        System.String  0 instance 00000000 _className
529b9e9c  4000003        8 ...ection.MethodBase  0 instance 00000000 _exceptionMethod
529bafb0  4000004        c        System.String  0 instance 00000000 _exceptionMethodString
529bafb0  4000005       10        System.String  0 instance 0ded2ac8 _message
529b3328  4000006       14 ...tions.IDictionary  0 instance 00000000 _data
529bb0f8  4000007       18     System.Exception  0 instance 00000000 _innerException
529bafb0  4000008       1c        System.String  0 instance 00000000 _helpURL
529bb350  4000009       20        System.Object  0 instance 0ded2e3c _stackTrace
529bb350  400000a       24        System.Object  0 instance 00000000 _watsonBuckets
529bafb0  400000b       28        System.String  0 instance 00000000 _stackTraceString
529bafb0  400000c       2c        System.String  0 instance 00000000 _remoteStackTraceString
529bc770  400000d       3c         System.Int32  1 instance        0 _remoteStackIndex
529bb350  400000e       30        System.Object  0 instance 00000000 _dynamicMethods
529bc770  400000f       40         System.Int32  1 instance -2147467262 _HResult
529bafb0  4000010       34        System.String  0 instance 00000000 _source
529ba3d4  4000011       44        System.IntPtr  1 instance        0 _xptrs
529bc770  4000012       48         System.Int32  1 instance -532462766 _xcode
5296de4c  4000013       4c       System.UIntPtr  1 instance  f43c2d1 _ipForWatsonBuckets
529a0798  4000014       38 ...ializationManager  0 instance 0ded2aac _safeSerializationManager
529bb350  4000001        0        System.Object  0   shared   static s_EDILock
    >> Domain:Value  03199208:NotInit  067cd0b0:NotInit  <<

The exception seems to indicate the crash was caused due to an interface not being found.  This indicates that something's wrong with proxy/stubs on his machine. At least IServiceProvider is failing. IE is usually the owner of the IServiceProvider proxy.
From the dump, it showed devenv.exe process crashed shortly after loading:  C:\Windows\SysWOW64\actxprxy.dll and C:\Windows\System32\mssprxy.dll

The issue turned out to be broken registration for IServiceProvider. The proxy-stub CLSID was wrong (it was referring to actxprxy.dll instead of ieproxy.dll on Windows 7 x64). Registering ieproxy.dll from an elevated cmd prompt resolved the issue.  regsvr32 "C:\Program Files (x86)\Internet Explorer\ieproxy.dll"  

On x86 systems,  regsvr32 "C:\Program Files\Internet Explorer\ieproxy.dll"