Intermittent HRESULT: 0x800A03EC errors during Exc

2019-07-16 06:19发布

问题:

I have a VB.NET 2.0 executable which I use to create numerous Excel files on a daily basis. Up until this point, it has been running on an XP box with Office 2007 installed (and using the Office 2007 Interop). It has worked fine for years.

Recently, the box failed and it was upgraded to a Windows 7 box, also running Office 2007. After that, I started getting intermittent errors during SaveAs functions at random points in the code.

What this means is that SOMETIMES the error doesn't happen at all. The code runs just fine. But SOMETIMES it happens on (for example) the 20th file that it's trying to SaveAs (there are many files containing multiple different types of data which are created by multiple loops). And then SOMETIMES it happens on (for example) the 50th file.

It's completely random in pretty much every way. I can't seem to track it down.

I've tried a few solutions, including the one found here: System.Runtime.InteropServices.COMException (0x800A03EC)

...even though that answer is for Office Interop 2003 (not 2007). I've also tried getting rid of the file extension in the Filename path (that was a suggestion from another site). The only other argument I use in the SaveAs function is the FileFormat (which I set to Excel8). I've seen some posts about security issues, but I don't see how this could be a security issue since it doesn't happen every time. I'm really at a loss for what could possibly be causing this. The code hasn't been changed since the XP box. The ONLY difference in this scenario is the O/S that the code is running on (and the fact that the new box is 64-bit).

WATYF