开发者

C# Console App with Excel Interop hangs as a scheduled task on Windows scheduler/ActiveBatch

I have a C# application that opens an Excel file on a network drive, reads data and writes to a database. I can run it manually from a batch file, but it isn't working when I run the batch file from Windows Scheduler or ActiveBatch. I don't actually get an error - the job just hangs when it tries to open the Excel workbook (not w开发者_运维问答hen it opens the application).

I am running under the same user credentials both when I run manually and from a scheduler. I'm using .NET 3.5 on Windows Server 2003 Enterprise SP2 with Office 2007.

I've tried the "Ogawa Hack" described here, and I've tried using a level of indirection by writing another batch file that would be run by the scheduler and would call the original file. Neither worked.

Any other ideas I can try?


Since your application will probably run on a server, I would recommend not using Excel Interop for this task. There are free .NET libraries available, which don't require Excel to be installed. For the older Excel <= 2003 format look here

http://jexcelapi.sourceforge.net/

(in the files section you will find a .NET port of this Java lib). For the newer XML based formats, you can use this one:

http://excelpackage.codeplex.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜