本文介绍了问题在asp.net办公自动化。我可以使用替代品,如开放式的办公室,如果我知道如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该上传PPT文件,然后提取其幻灯片图像的ASP.NET 2.0 Web应用程序。对于我已经进口office.dll和Microsoft.Office.Interop.PowerPoint.dll组件和写了下面的code

I have a ASP.NET 2.0 web application that should upload a ppt file and then extract its slides to images. For that I have imported office.dll and Microsoft.Office.Interop.PowerPoint.dll assemblies and wrote the following code

public static int ExtractImages(string ppt, string targetPath, int width, int height)
    {
        var pptApplication = new ApplicationClass();

        var pptPresentation = pptApplication.Presentations.Open(ppt, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);

        var slides = new List<string>();

        for (var i = 1; i <= pptPresentation.Slides.Count; i++)
        {
            var target = string.Format(targetPath, i);
            pptPresentation.Slides[i].Export(target, "jpg", width, height);
            slides.Add(new FileInfo(target).Name);
        }

        pptPresentation.Close();

        return slides.Count;
}

如果我运行我的本地机器这个code,在asp.net中或可执行文件,它完美地运行。但如果我尝试在生产服务器上运行它,我得到以下错误:

If I run this code in my local machine, in asp.net or a executable, it runs perfectly. But If I try running it in the production server, I get the following error:

System.Runtime.InteropServices.COMException(0x80004005的):PowerPoint中
  无法打开文件。在
  Microsoft.Office.Interop.PowerPoint。presentations.Open(字符串
  文件名,MsoTriState类型只读,MsoTriState类型无题,MsoTriState类型
  WithWindow)在PPTImageExtractor.PptConversor.ExtractImages(字符串
  caminhoPpt,字符串caminhoDestino,的Int32 largura,阿尔图拉的Int32,字符串
  caminhoThumbs,的Int32 larguraThumb,的Int32 alturaThumb,布尔geraXml)
  在Upload.ProcessRequest(HttpContext的背景下)

该过程与用户NT AUTHORITY \\ NETWORK SERVICE运行。 IIS配置为使用匿名身份验证。匿名用户是管理员,我这样设置,让应用程序,而不必担心权限运行。

The process is running with the user NT AUTHORITY\NETWORK SERVICE. IIS is configured to use anonymous authentication. The anonymous user is an administrator, I set it like this to allow the application to run without having to worry about permissions.

在我的机器我有Office 2010的β1的。我曾与可执行文件与Office 2007的PC机测试,以及。如果我运行在服务器中的可执行文件code,安装了Office 2003,它运行完美。

In my development machine I have office 2010 beta1. I have tested with the executable in a pc with office 2007 as well. And if I run the code from the executable in the server, with office 2003 installed, it runs perfectly.

要确保不会有与权限的任何问题,大家都在服务器具有完全访问网站。该网站是在IIS7和经典模式运行。

To ensure that there wouldn't be any problems with permissions, everyone in the server has full access to the web site. The website is running in IIS7 and Classic Mode.

我还听说,开放式办公室有,应该是能够做到这一点的API,但我无法找到任何关于它。我不介意使用的DllImport做我必须做的,我可以在Web服务器上安装开放式办公。不要担心重写这个方法,只要参数都是一样的,一切都将正常工作。

I also heard that Open-office has an API that should be able to do this, but I couldn't find anything about it. I don't mind using DLLImport to do what I have to do and I can install open-office on the web server. Don't worry about rewriting this method, as long as the parameters are the same, everything will work.

我AP preciate你的帮助。

I appreciate your help.

推荐答案

永远不要使用Office互操作从ASP.NET应用程序。请参见的服务器端自动化。

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

不过,如果你没有选择,Windows Server 2008上,你需要创建以下目录得到这个工作:

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

的Windows 2008服务器的x64:C:\\ WINDOWS \\ Syswow64资料\\ CONFIG \\ systemprofile \\桌面
的Windows 2008服务器的x86:C:\\ WINDOWS \\ system32 \\设置\\ systemprofile \\桌面

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

这篇关于问题在asp.net办公自动化。我可以使用替代品,如开放式的办公室,如果我知道如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 07:54