Windows Service中的Excel Interop在EXCEL.EXE中崩溃,版本:16.0.4966.1000,模块:oart.dll,版本:16.0.4900.1000

问题描述 投票:0回答:1

请不要发表评论,我不知道Windows Service不支持Interop模式。 :-)

我有一个带有表格和图表的Excel文件。它在Windows Server 2012R2和Excel 2003中作为Interop模式的Windows服务在Windows Server 2012R2下运行了几年,没有任何问题。

更改为Windows Server 2019和Excel 2016后,无法再使用以下代码打开此文件:

Application excelApp = new Application();
Workbooks  workBooks = excelApp.Workbooks;
workBook = workBooks.Open(<Path To Excel-File>, 0, false, 5,
     Missing.Value, Missing.Value, true, XlPlatform.xlWindows, "\t", true, false, 0, true);

它导致我的错误处理在:

System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. 
(Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

事件日志显示:

Name der fehlerhaften Anwendung: EXCEL.EXE, Version: 16.0.4966.1000, Zeitstempel: 0x5e205905
Name des fehlerhaften Moduls: oart.dll, Version: 16.0.4900.1000, Zeitstempel: 0x5d53033a
Ausnahmecode: 0xc0000005
Fehleroffset: 0x0006e67e
ID des fehlerhaften Prozesses: 0x1a38
Startzeit der fehlerhaften Anwendung: 0x01d5e64d380ea691
Pfad der fehlerhaften Anwendung: C:\Program Files (x86)\Microsoft Office\Office16\EXCEL.EXE
Pfad des fehlerhaften Moduls: C:\Program Files (x86)\Microsoft Office\Office16\oart.dll
Berichtskennung: b6eee871-9dca-4ddc-8d4b-cdd9f58f871b
excel windows service automation interop
1个回答
0
投票

经过数小时的文件测试后,我创建了一个新的Excel文件,打开它并将其读取或写入单元格没有问题。比起从文件中删除越来越多的表格和图表,最终我发现了崩溃原因:

在任何图表或表格中是否有任何嵌入式图像,无法使用Windows Service的Interop打开文件。

使用命令行应用程序以相同的代码打开文件(带有内部图像)绝对没有问题。

但是可以将图像放置在页眉或页脚中。没问题。疯狂。

© www.soinside.com 2019 - 2024. All rights reserved.