We have an application that has been running for several years with no issues. About a month ago we started getting errors when using any Office.Interop object. Word, Excel, and Outlook (Office 365)...
We have read every posting about office installations, registry entries and so forth. None of them have helped. We have about 1200 users in 5 different countries and having them all constantly doing office repair is not practical, nor does it seem to be working. The Outlook add-ins that we have operating all seem to be working fine. We have brought this up to the global IT group, which is in Europe, and they don't seem to feel it is something that they are doing with the updates. Since the error is generating our of our software, the problem is on us.
To make it more aggravating, not all the machines have this problem at the same time. Out of say 20 machines in an office, 5 may have this issue for two days, then start working again. Two days later four different machine have this problem and the rest are working fine.
So, the question is, is there a work around to prevent the Interop from being subject to this sort of bug, and if not, are there any other viable solutions for taking word documents, filling them in and then mailing them out as PDF's? Has anyone else had this on an enterprise level? Seems that all of the postings about this deal with single machines and local fixes.
This is the code that generates the error, and the error below.
private void button1_Click(object sender, EventArgs e)
{
Outlook.Application outlookApp;
Outlook._MailItem oMailItem;
outlookApp = new Outlook.Application();
// Error generates here.
oMailItem = outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
}
System.InvalidCastException: 'Unable to cast COM object of type 'Microsoft.Office.Interop.Outlook.ApplicationClass' to interface type 'Microsoft.Office.Interop.Outlook._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063001-0000-0000-C000-000000000046}' failed due to the following error: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND)).'