我收到錯誤:System.Runtime.InteropServices.COMException(0x80080005)
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} failed due to the following error: 80080005.
爲這裏的代碼塊行PowerPoint.Application PowerPoint_App = new PowerPoint.Application();
:
using (new Impersonator(Installs.Current.PPTUser, null, Installs.Current.PPTPassword))
{
PowerPoint.Application PowerPoint_App = new PowerPoint.Application();
PowerPoint.Presentation presentation = null;
try
{
PowerPoint_App.Visible = MsoTriState.msoTrue;
presentation = PowerPoint_App.Presentations.Open(
strPptFilePath, Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoTrue);
for (int i = 0; i < presentation.Slides.Count; i++)
{
readSlides(presentation, i);
}
presentation.Close();
PowerPoint_App.Quit();
}
catch (Exception ex)
{
strSuccess = ex.ToString();
MindMatrix.Libraries.Entities.ExceptionMessage.HandleException(ex, null);
}
finally
{
Marshal.FinalReleaseComObject(presentation);
Marshal.FinalReleaseComObject(PowerPoint_App);
}
}
每當我跑該代碼第一次,它完美的作品,但它然後創建PowerPoint的過程(可以在任務管理器中看到)。我用PowerPoint_App.Quit();
退出已經打開的進程,但它不起作用,並引發錯誤。我去任務管理器並從那裏結束進程,然後就可以再次工作了。
我退出代碼的過程中做錯了什麼,或者有什麼其他的方式嗎?
是顯示在同一時間一個錯誤的PowerPoint的用戶界面? Powerpoint COM服務器在受到很大壓力時可能會很容易失敗(例如,在一個循環中)。 –
我不打開ppt ui.i使用來自ppt幻燈片的圖像和文本對象。它們在編輯器中被進一步使用。 –