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

unable to cast com object of type visual studio
unable to cast com object of type to interface type
unable to cast com object of type outlook
unable to cast com object of type library not registered
unable to cast com object of type c#
vb net unable to cast com object of type
system invalidcastexception unable to cast com object of type
unable to cast com object of type 'microsoft office interop powerpoint applicationclass

I have 3 SSIS packages. Two out of the 3 SSIS packages work perfectly, the third. Which is a copy of the 2nd one, except changing connection strings keeps throwing the problem:

Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSObject100'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{D4E5AF42-7999-473C-8082-6EFC676953C4}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).

It has been doing this ever since I copied the package over. I have followed through online guides and run the regsvr32 dts.dll and this said it was successful but nothing has changed. I still get the error, why is this?

The SSIS package seems to validate my containers, it takes a long time to do this compared to the other two and then fails later on in the validation throwing the above error message.

You can't just copy the package, but you need additionally to change the name and generate new GUID (which identifies the COM object) for this package. Check this MSDN article for more info.

Resolving 'Unable to cast COM object' errors when using MS-O, Unable to cast COM object of type 'System.__ComObject' to interface type ' Microsoft.Office.Tools.Excel.Worksheet'. This operation failed� Unable to cast COM object type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000048}' failed due to the following error: Library not registered.

I hope it helps others. The solution worked for me:

  1. I registered the assembly using the gacutil.exe. My SSIS project target server version was SQL 2012. So, I was using the DTSPipelineWrap.dll version 11.0. I opened the "Developer Command Prompt for VS2015" in Administrator mode, then typed the following command: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe /i "C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.DTSPipelineWrap.dll"
  2. Then from my SSIS script task, References--> I removed the existing DTSPipelineWrap which was using the assembly from the location "C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.DTSPipelineWrap.dll". Then in the References folder, right click-->Add Reference-->Browse find the assembly from the location "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.DTSPipelineWrap\v4.0_11.0.0.0__89845dcd8080cc91\Microsoft.SQLServer.DTSPipelineWrap.dll"
  3. Click Ok. Rebuild the code and executed the package. It has worked for me.

unable to cast COM object of type 'microsoft.Office , If this is not a code related error than please remove below given key from registry. Steps: Start--> Run --> regedit� Excel Application Scope: Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘System.Runtime.InteropServices.ComTypes.IConnectionPointContainer’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{B196B284-BAB4-101A-B69C-00AA00341D07}’ failed due to the following error: The requested object does not exist

In my case this is was a validation overload/timeout, the package contained references to hundreds of tables.

Opening the offending data flow forced re-validation and cleared the error.

Error: Unable to cast COM object of type – Support Topics, Complete text of error message is: An unexpected error has occurred: Unable to cast COM object type 'Microsoft.Office.Interop.Excel. Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Tools.Excel.Worksheet'. This operation failed because the QueryInterface call on the COM component for the interface with IID

In case this might help someone: I got this error due to timeout issues caused by a poorly optimised query. There was nothing inherently wrong with the SSIS package and it ran fine once i fixed the problem in the DB Source.

Unable to cast COM object when exporting to Excel from Team , Unable to cast COM object of type 'Microsoft. Office. Interop. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: The interface is unknown. Symptom: When I attempt to merge to Word, I receive the Error: "Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000

How to solve “Unable to cast COM object of type Microsoft.Office , ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'” this operation failed because the QueryInterface call on the com� Thus, to resolve the “Unable to cast COM object of type ‘CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass’ to interface type ‘CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'” issue, make sure to remove all old Crystal Reports assemblies from Reference list in all projects.

"Unable to cast COM object" error – Support Home, DocumentClass' to interface type 'Microsoft.Office.Interop.Word._Document'. This operation failed because the QueryInterface call on the COM� Error: "Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'" when attempting to merge to Microsoft Word; Error: “Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))” when I edit a template or try to mail merge

Solved: Act!, Solved: We are getting this error "Unable to cast COM object of type 'Microsoft. Office.Interop.Outlook.ApplicationClass' to interface type. Message: Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.Office.Interop.Excel._Workbook’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{000208DA-0000-0000-C000-000000000046}’ failed due to the following error: System call failed.

Comments
  • My second package is a copy of the third with different connection strings and it works fine. I will create a new package tomorrow and copy the logic itself over. Cheers. I'll let you know how it turns out
  • This did not fix my problem