简体   繁体   English

应用程序使用 Microsoft.Office.Interop.Excel 打开 Excel 文件与服务器上的 RDP 会话冲突

[英]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.我最近在 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).我使用不同版本的 Excel(2016、2019、365)进行了测试,问题是在服务器上打开远程桌面会话时随机发生的(从某些机器启动的某些 RDP 不会导致任何问题,而其他一些导致应用程序无法在职的)。

The code opening excel is pretty simple and was working for couple of years without any issue:代码打开 excel 非常简单,并且工作了几年没有任何问题:

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. (来自 HRESULT 的异常:0x800706BE) System.Runtime.InteropServices.COMException (0x800706BE):远程过程调用失败。 (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) (来自 HRESULT 的异常:0x800706BE)在 Microsoft.Office.Interop.Excel.Workbooks.Open(字符串文件名、对象更新链接、对象只读、对象格式、对象密码、对象 WriteResPassword、对象 IgnoreReadOnlyRecommended、对象原点、对象分隔符、对象可编辑、对象通知、对象转换器、对象 AddToMru、对象本地、对象损坏加载)

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.对于冲突的 RDP,我注意到 rdpinput.exe 进程被激活,而没有冲突的进程则没有激活该进程的痕迹。 If no RDP session is opened on that server, everything works fine.如果该服务器上没有打开 RDP 会话,则一切正常。

Any idea how to solve this issue ?知道如何解决这个问题吗? We still need to be able to RDP the server.我们仍然需要能够 RDP 服务器。

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.事实证明,我们中的许多人都更换了笔记本电脑,并且该型号的触摸屏在 Windows 中处于活动状态。 If we connect on the VM with a laptop that had touch screen active, then this error started to happen.如果我们使用触摸屏处于活动状态的笔记本电脑连接 VM,则会开始发生此错误。

SOLUTION: Do not connect to the VM with a workstation that has the touch screen active.解决方案:不要使用触摸屏处于活动状态的工作站连接到 VM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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