Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Document.close()永远使用/nots';我不能在C#中工作,如何解决这个问题?_C#_Ms Word_Office Interop - Fatal编程技术网

Document.close()永远使用/nots';我不能在C#中工作,如何解决这个问题?

Document.close()永远使用/nots';我不能在C#中工作,如何解决这个问题?,c#,ms-word,office-interop,C#,Ms Word,Office Interop,我有以下代码: // Writing a byte[] to temporary folder as a word file File.WriteAllBytes(Path.Combine(Path.GetTempPath(), formLanguage.FileName), formLanguage.FormFile); var app = new Microsoft.Office.Interop.Word.Application(); Document doc = app.Document

我有以下代码:

// Writing a byte[] to temporary folder as a word file
File.WriteAllBytes(Path.Combine(Path.GetTempPath(), formLanguage.FileName), formLanguage.FormFile);

var app = new Microsoft.Office.Interop.Word.Application();
Document doc = app.Documents.Open(Path.Combine(Path.GetTempPath(), formLanguage.FileName));

// what my main goal is to count the pages
var pageCount = doc.ComputeStatistics(
   Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages);

formLanguage.NumberOfPages = pageCount;
object saveOption = WdSaveOptions.wdDoNotSaveChanges;
object originalFormat = WdOriginalFormat.wdOriginalDocumentFormat;
object routeDocument = false;

// here is where the debugger just doesn't continue.
doc.Close(saveOption, originalFormat, routeDocument);
app.Quit();

doc.Close
被称为“我的C#桌面应用程序”时,它就被卡住了,需要花费很长时间。有人知道我的错误是什么吗?或者是否有可能像这样关闭word文档?

您能让word在桌面上可见,以查看是否有任何阻塞(如messagebox)?