Use Office Interop on ASP.net MVC6 website

大兔子大兔子 提交于 2019-11-26 14:50:14

问题


I want to generate word documents from my ASP.net MVC 6 website. I've implemented several ways to generate a document in a POC : DocX, NetOffice, OpenXml, COM Interop objects. I was seduced by it.

I made a Console App to test and it works.

But, with ASP.net MVC6, we can't reference Console App's or COM Assemblies. We need to create "Console App (Package)".

How can I add COM Assemblies to my ASP.net MVC 6 website ?


回答1:


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.

You can read more about that in the Considerations for server-side Automation of Office article.

Consider using third-party components designed for the server-side execution or if you deal with open XML documents you may use the Open XML SDK, see Welcome to the Open XML SDK 2.5 for Office for more information.



来源:https://stackoverflow.com/questions/30663123/use-office-interop-on-asp-net-mvc6-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!