System.Runtime.InteropServices.COMException (0x800

2019-06-14 01:36发布

We are trying to open a Word template which resides on a Shared Drive using Office Interop Services on an MVC application.The solution is working locally, but once is deployed to the server the following message appears:

The File was not created: System.Runtime.InteropServices.COMException (0x800A1436): This file could not be found

ApplicationPool is running under a domain user account which already has permissions on the shared drive.

Any suggestion?

2条回答
淡お忘
2楼-- · 2019-06-14 01:44

You may consider using the Open XML SDK for dealing with open XML documents (.docx), see Welcome to the Open XML SDK 2.5 for Office. Or any other third-party components designed for the server-sider execution (for example, Aspose).

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

查看更多
来,给爷笑一个
3楼-- · 2019-06-14 02:07

Kb257757 https://support.microsoft.com/en-us/help/257757/considerations-for-server-side-automation-of-office

Server-side automation of office is not supported using Interop, try using an XML based approach such as ClosedXML which is available from NuGet.

查看更多
登录 后发表回答