私が実行しているコードは次のとおりです。
MsoTriState readOnly = MsoTriState.msoTrue;
MsoTriState untitled = MsoTriState.msoFalse;
MsoTriState withWindow = MsoTriState.msoFalse;
string filePath; //some file path to a pptx
ppt.Application app = null;
ppt.Presentations presentations = null;
ppt.Presentation presentation = null;
app = new ppt.Application();
presentations = app.Presentations;
presentation = presentations.Open(filePath, readOnly, untitled, withWindow);
System.Runtime.InteropServices.Marshal.ReleaseComObject(presentation);
presentation = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(presentations);
presentations = null;
app.Quit(); //HANGING HERE
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
app = null;
これは、PowerPoint アプリケーションを開いて閉じる非常に基本的なコードです。しかし、何らかの理由で、app.Quit()
通話が保留になっています。また、理由はわかりませんが、ComRelease プレゼンテーションの行をコメントアウトすると、ハングしません。別のハックは、app.Quit を呼び出す前に app.Visible = msoTrue にすることです。
ここで何が起こっているか知っている人はいますか?ComRelease 手順を台無しにしていますか?