0
votes

I have had code working in an C# .net 2013. that exports the DGV to excel. However it has stopped working as of this morning, its been about a month since I have opened the code. Now I am getting an error:

Additional information: 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 have found a number of answers else ware that says to removing the Regedit key? What happend and which key do I need to remove?

1
Additional, a lot of posts talk about having downgraded office, we have not down graded but went to office 365Lee Hopkins
Try deleting the three office references (Excel, Office, VBE) from the "References" node in the Solution Explorer. Then add the Excel Com reference again. Then clean and rebuild the project.TnTinMn
The only references i have is microsoft.office.interop.excel.Lee Hopkins
This link seems to encompass the basic idea, regardless of the specific version(s) in question.DonBoitnott
I seen that article but i do not have the 000208D5-0000-0000-C000-000000000046 value in typelib. or any typelibs that have a \1.6 or 1.7... they are all just a guid wit a deafult type data (value not set)Lee Hopkins

1 Answers

0
votes

In my case it was a matter of explicitly defining the use of non 32 bit version of the library. For doing so in visual studio, I had to tick and then untick the box "Prefer 32-bit" in the build section of the project configuration, which added <Prefer32Bit>false</Prefer32Bit> in the .csproj file.