简体   繁体   中英

Application using Microsoft.Office.Interop.Excel to open excel file conflict with RDP sessions on the server

I have a strange behavior started occurring recently on Windows Server 2016/2019. I performed tests using different versions of Excel (2016, 2019, 365) and the issue happened randomly when a remote desktop session is opened on the server (some RDP initiated from some machines do not cause any issue while some others led to the application not working).

The code opening excel is pretty simple and was working for couple of years without any issue:

string filePath = @"C:\excelFilePath.xlsx";
Application excelApp = new Application();
excelApp.Workbooks.Open(filePath , true, true);

When it failed we got the following exception:

The remote procedure call failed. (Exception from HRESULT: 0x800706BE) System.Runtime.InteropServices.COMException (0x800706BE): The remote procedure call failed. (Exception from HRESULT: 0x800706BE) at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)

For the conflicting RDP i noticed that rdpinput.exe process was activated while with non-conflicting one there no trace of activation of the that process. If no RDP session is opened on that server, everything works fine.

Any idea how to solve this issue ? We still need to be able to RDP the server.

Thank you!

We found a culprit. It turns out that many of us have had our laptop changed, and this model had a touch screen active in Windows. If we connect on the VM with a laptop that had touch screen active, then this error started to happen.

SOLUTION: Do not connect to the VM with a workstation that has the touch screen active.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM