Problems with office automation in asp.net. I can use alternatives such as open-office, if I knew how

余生长醉 提交于 2019-11-29 04:51:41
Murthy Pantham

Don't ever use Office Interop from an ASP.NET application. See Considerations for server-side Automation of Office.

However, if you have no alternative, on Windows Server 2008 you need to create the following directories to get this to work:

Windows 2008 Server x64: C:\Windows\SysWOW64\config\systemprofile\Desktop Windows 2008 Server x86: C:\Windows\System32\config\systemprofile\Desktop

When considering using Office Automation on the server, you might want to take a read through the info in the following KB article.

http://support.microsoft.com/kb/257757

A key phrase from the above link

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.

And I can confirm that the above is very true, and not just MS trying to discourage you...

In my situation (converting presentation to video, and I have very similar problem with open stuff) this helps:

Creating the following directories:

C:\Windows\SysWOW64\config\systemprofile\Desktop

C:\Windows\System32\config\systemprofile\Desktop (I don't have this)

My operating system Windows Server 2012 R2 Standard

The Interop libraries require that the application in question be installed on the machine from which they are running. I.e., in order for this to work on your production server, you will need to have Office installed on that server. This is generally an awful idea. There are many issues with type of setup as each time someone makes a request, a new instance of the application in question (in your case PowerPoint) is launched.

If you want to parse PowerPoint files on a central server, then you should use a library that reads PowerPoint files. I know that Aspose makes such product (Aspose.Slides) but there are others as well.

If the documents are in PowerPoint 2007, you might be able to parse the Open Office XML for the data you want. See Introducing the Office (2007) Open XML File Formats and Open XML SDK 2.0 for Microsoft Office for more.

I might be wrong, started looking into a similar thing recently. But you should not need office installed on a machine to create or edit 2007+ office files. They are basically zip files with a different extention. If you rename it to .zip you should see all the files and be able to edit them directly.

It can then be unzipped and all the files are there for you. You can create new files in a similar fashion

ptrc

Don't ever use Office Interop from an ASP.NET application. See Considerations for server-side Automation of Office.

However, I just wanted to note here that I had to do the fix described by Murthy Pantham on a Windows 7 Professional 64 bit machine with Office 2010. It did not have Windows 7 Service Pack 1 or Office 2010 Service Pack 3 installed. So the lesson here is apparently that fix is not limited to Server 2008. Hope this helps someone.

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