Unable to load excel file using Microsoft.Office > interop.Excel - c#

In my WPF application I am using Microsoft.Office.Interop.Excel to import data from excel file. I have been using this code for last couple of months and it has been working just fine for me. Today all of a sudden when I ran the utility I got the following error.
Unable to cast COM object of 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-000000000046}' failed due to the
following error: Library not registered. (Exception from HRESULT:
0x8002801D (TYPE_E_LIBNOTREGISTERED)).
I had originally Office 2013 installed but 2 months ago I uninstalled and installed the 2007 version. Everything was working fine until now.
I have read on different posts to delete the registry entry corresponding to the above IID. I have tried doing that but no help. I uninstalled/repaired Office as well but no help.
I have tried to register the Microsoft.Office.interop.excel.dll using regasm.exe as well but again no luck. Whats the issue here?

I had a some problems with Interop. then I switched to Microsoft.Jet.OLEDB.4.0 don't know if it helps, but I found it to be much more stable.

Related

Error : 800700c1 in instantiating an object for Microsoft.Office.Interop.Excel.Application

I am getting the below error when instantiating the Microsoft.Office.Interop.Excel.Application() for generating Excel from the winforms app.
This was working before and suddently it stopped working eventhough there was no change in code and in version of excel. Only change I could see is there were some windows 10 updates getting installed in past weeks but I am not sure whether that was the cause for the problem
retrieving the com class factory for component with clsid {00024500-0000-0000-c000-000000000046} failed due to the following error : 800700c1.
I could see many solutions for access denied (error: 80070005 Access is denied) for the same type of operation, but none for error : 800700c1.
I am running the application in 32 bit and I have re-installed the office 2016 (32-bit) suite but still I am getting the error.
Any help in direction of solving would help.
Deleting the file "C:\Program" fixed the issue. No idea how the file was created and why deleting it solve the excel generation problem.
Just to piggyback off of Vignesh AJ's solution, this Program file seems to have appeared after a Citrix Workspace for Windows update. The file can be moved or deleted from C drive to solve the problem.
In my case c:\Program was created by Notepad++, and yes removing it did help.

MSProject COM Interop unstable behavior

We are extensively using COM Interop with MSOffice applications, and one of them - MSProject 2013, is behaving very unstable and strange.
Sometimes it starts just fine, and works fine, but from time to time it is bugging us with following error:
Retrieving the COM class factory for component with CLSID
{36D27C48-A1E8-11D3-BA55-00C04F72F325} failed due to the following
error: 80080005 Server execution failed (Exception from HRESULT:
0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
This can happen at any time, does not matter if windows was rebooted a few seconds ago, or uptime is several hours and MSProject was opened and closed several times.
What can we do to solve, or at least diagnose root cause of such a behavior?
this is a generic the best answer
Using DCOMCNFG.exe. Open it and go to: Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application.
Open the properties, select Identity tab and select the interactive user.
come from this link Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))
but the actual error caused a memory issue which leaded to the exception from hresult 0x80080005 error.
check if maybe open file and didn't close it after reading msProject check the behavior of the code.
Also i recommend to change COM and read MsProject from XML to be faster and more clear than interop

SSIS Script Component Cannot Load Assembly Until Manually Opened

I am creating a SSIS project via Biml (Using the current version of BimlExpress per the Varigence BimlExpress page) that uses a script component within a Data Flow Task. The project is created without issue however errors when it gets to the Script Component:
Could not load file or assembly 'Microsoft.SqlServer.DTSPipelineWrap, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
at ScriptMain.PreExecute()
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PreExecute()
I can see this dll within the GAC and when I try to add the reference manually, SSIS states that I can't add it as it is already included in the project.
However, if I open the Script Component and manually Build it - but change nothing else - the Data Flow Task will run through without issue.
To clarify, I know I have changed nothing else as I am recreating this project from the Biml each time I want to test a new approach, which provides a consistent baseline.
Does anyone know why a Script Component that includes a reference to a GAC dll, will only work when manually Built but not beforehand?
I have used this exact Biml before without issue, though on a different environment. Worked using Visual Studio 2012 against a SQL Server 2016 instance yet doesn't here within Visual Studio 2015 (targeting 2012) against a SQL Server 2016 instance.
For further context I have also tested this outputting the SSIS Project targeted at SQL Server 2012, 2014 and 2016 with the exact same error message.
Update
This appears to definitely be a dll version problem in the project as output from BimlExpress, in that if I manually create the v4.0_14.100.0.0__89845dcd8080cc91 folder with the version 13 dll inside at C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.DTSPipelineWrap the script component now errors out with the following:
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData100'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{ID removed just in case}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.HandleUserException(Exception e)
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PreExecute()
at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPreExecute(IDTSManagedComponentWrapper100 wrapper)
I guess your problem may be related to the Express version.
See at the related page the differences between Express and BimlStudio versions (Feature Comparison Chart under "Compare with BimlStudio" button):
https://www.varigence.com/BimlExpress
I had the same issue with the Data Profiling component. I used the following post.
ssis-data-profiling-task-editor-return-error-codes

Unable to cast COM object - error: No such interface supported

I've got this annoying issue in here when using a VB6 DLL (AB5COM.dll) in my webAPI project.
All is working fine in my local VS2015. The problem occurs only in my remote IIS 7.5 (Win2008 R2) after deploying the published site.
I'm using this DLL in 2 projects of my solution.
I've tried several things -
Generating interop.AB5COM
Disable embed and copy local
platform change to x86
APP POOL supports 32bit
[assembly: ComVisible(true)]
Adding [Guid("xxxxxxx-xxxxx-xxxxxx-xxxxxx")] as attribute in my class
All was useless. Local VS2015 works, remote IIS7.5 fails with this exception.
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'AB5COM.trxAB5core'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{AF42661C-D369-454A-A005-55D51037166A}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I also can't find which DLL I need to register using regsvr32 since the COM dll isn't published, and the interop cannot be registered.
Would appreciate your help on this.
Thx
Ok, since no answer on this, I had to make some moves...
The remote IIS environment is my TEST server, so I've installed VS2017 with my solution, ran my app (success) and published (success).
So currently I have no issues with this COM DLL which brings the conclusion that this is a pure REGISTRY issue. The VS2015 knows how to register the correct DLL and then all works perfectly.
Now, I need to figure how to make this working on my Production...
Although this is NOT a proper solution, I hope my personal post helps anyone.

Exceptions from Excel API after downgrading from 2013 to 2010

After downgrading from Excel 2013 to 2010 (i.e. removing 2013 and installing 2010) when I try to access the Excel OM from my add-in like this:
if (this.Application.ActiveWorkbook == null)
{
return;
}
I get the following Exception:
Unable to cast COM object of type 'System.__ComObject' 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-000000000046}' failed due
to the following error: Library not registered. (Exception from
HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
I have taken the following steps to resolve the issue but none have worked:
Repaired the office installation
Uninstalled and reinstalled
Cleared out all office 15 references from the registry
Re-registered Excel ("C:\Program Files (x86)\Microsoft Office\Office14\excel.exe" /o)
However, nothing seems to work. Is there something I'm missing or do I actually have to wipe the machine?
EDIT:
My guess is that there is still come conflict in the registry but I have no idea where...
Thanks in adv!
Found the solution - I forgot to remove one reference to Excel 2013:
HKEY_CLASSES_ROOT\TypeLib{00020813-0000-0000-C000-000000000046}\1.8
After removing 1.8 my corrected registry looks like this:
...
Credit: http://www.c-sharpcorner.com/Forums/Thread/203666/unable-to-cast-com-object-of-type-microsoft-office-inte.aspx

Categories