我在C#.NET中開發了一個使用Excel Interop的控制檯程序。 該程序在我的開發機器和Windows Server 2008上工作得很好,如果我從命令行運行它。無法使用Excel Interop安排程序
當我嘗試安排任務每天運行它,我得到這個惱人的互操作錯誤:
02/11/2011 00:30:05,000 [1] FATAL My.Program [(null)] - Unable to Microsoft Office Excel open file 'E:\excel.xls' by one of several reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as the currently opened book.
System.Runtime.InteropServices.COMException (0x800A03EC): Unable to access the Microsoft Office Excel file 'E:\excel.xls' by one of several reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as the currently opened book.
in Microsoft.Office.Interop.Excel.Workbooks.Open (String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, IgnoreReadOnlyRecommended Object, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
文件「E:\ excel.xls」存在,如果在程序啓動時完全關閉,因爲如果我嘗試在我的命令行中運行相同的程序,它會按預期結束。
我也設置我的任務以管理員身份運行,所以它不應該是權限問題。
你能幫我嗎?
你找出解決方案還是解決這個問題?我有完全相同的問題,你可以請你發佈你的解決方案嗎?謝謝! – dpac 2011-10-25 20:39:17