出内存故障自动VSTO简报的API [英] Out of Memory failure automating VSTO Powerpoint API

查看:146
本文介绍了出内存故障自动VSTO简报的API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VSTO简报API自动的PowerPoint文件的创建。我发现是,使用最基本的调用创建从Windows 7系统上的Web应用程序一个PowerPoint文件会导致内存不足的错误(即操纵打开的文件也未能其他VSTO话费):

 的PowerPoint presentation presentation = _pp presentations.Add(Office.MsoTriState.msoTrue)。
        字符串输出目录= getOutputDirectory();
        presentation.SaveAs(输出目录+\\\\ CreateSlideTestOutput.pptx
                            PowerPoint.PpSaveAsFileType.ppSaveAsDefault,Office.MsoTriState.msoTrue);

这是我收到的错误是内存不足在正在取得任何VSTO API调用来操纵一个文件(例如,保存或增加一个PowerPoint幻灯片)。

不过,我发现,如果我在单元测试运行相同的code,或者作为一个用户可执行文件(.exe),我没有问题添加内容,处理和保存PowerPoint文件。

但是,当我试图创建一个Windows服务来自动在我的用户可执行使用相同的code,我又收到内存不足错误。我可以在我的服务设置一个断点,并认为它是从我的web应用程序调用时失败的完全相同的VSTO的API调用失败。

有没有人有而我的应用程序池中的线程解释为什么用户可执行的线程可以没有任何问题,什么那么(和内存中没有观察到跳)执行VSTO的API调用,或Windows服务线程经常遇到内存不足错误<? / p>

解决方案

http://support.microsoft。 COM / KB / 257757

自动化Office文档(与互操作的.dll),而不需要用户上下文不稳定的MS支持。他们建议使用像的OpenXML的SDK另一种解决方案:

http://www.microsoft.com/en-我们/下载/ details.aspx?ID = 5124

I am using the VSTO Powerpoint API to automate the creation of Powerpoint files. What I have found is that using the most basic call to create a Powerpoint file from a web application on a Windows 7 system causes an out of memory error (other VSTO calls that manipulate an open file also fail):

PowerPoint.Presentation presentation = _ppPresentations.Add(Office.MsoTriState.msoTrue);
        string outputDirectory= getOutputDirectory();
        presentation.SaveAs(outputDirectory+ "\\CreateSlideTestOutput.pptx",
                            PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Office.MsoTriState.msoTrue);

The error that I receive is "Insufficient Memory" at whatever VSTO API call is being made to manipulate a file (for instance, saving or adding a slide to a powerpoint).

However, I found that if I run the same code in a unit test, or as a user executable (.exe), I have no problems adding content, manipulating and saving Powerpoint files.

But then, when I tried to create a Windows service to automate the same code used in my user executable, I am receiving an Insufficient Memory error again. I can set a breakpoint in my service and see that it is failing on the exact same VSTO API calls that failed when called from my web application.

Does anyone have an explanation why the user executable thread can execute VSTO API calls without any issue what so ever (and no observable jump in memory) whereas my App pool thread, or Windows service thread always runs into Insufficient Memory errors?

解决方案

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

Automating Office documents (with the Interop .dlls) without a user context isn't "stability" supported by MS. They advise to use another solution like the OpenXML SDK:

http://www.microsoft.com/en-us/download/details.aspx?id=5124

这篇关于出内存故障自动VSTO简报的API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆