c# interop winword.exe doesn't Quit()! -


i feed multiple docs below method , see winword.exe disapear expected on over 15 diferente pcs running winxp 32bit win8 64bit having office 2000 onwards. on 1 nightmare pc has trend's antivĂ­rus running, winword.exe (always, every time) interrupts loop "file in use" exception (turning trends off allows work again). ideias keep trends on?

void loop() { microsoft.office.interop.word._application app = new microsoft.office.interop.word.application(); app.visible = false; app.screenupdating = false; app.displayalerts = wdalertlevel.wdalertsnone;  microsoft.office.interop.word._document doc = app.documents.open(filepath, false, true, false); doc.activate(); doc.disablefeatures = true;  doc.exportasfixedformat(newfilename, wdexportformat.wdexportformatpdf, false,wdexportoptimizefor.wdexportoptimizeforonscreen, wdexportrange.wdexportcurrentpage, 1, 1, wdexportitem.wdexportdocumentwithmarkup, false, false, wdexportcreatebookmarks.wdexportcreatenobookmarks, true, false, true, type.missing);  ((microsoft.office.interop.word._document)doc).close(wdsaveoptions.wddonotsavechanges); marshal.releasecomobject(doc); marshal.finalreleasecomobject(doc);  ((microsoft.office.interop.word._application)app).quit(wdsaveoptions.wddonotsavechanges); marshal.releasecomobject(app); marshal.finalreleasecomobject(app);  gc.gettotalmemory(false); gc.collect(); gc.waitforpendingfinalizers(); gc.collect(); gc.gettotalmemory(true); } 

i've had similar issues av's.

you need to put try catch, , in catch, add sleep() , try again.

i ended having work out how big file determine how long sleep should (based upon how long scan going on proportional time took scan).

hope enough going?


Comments

Popular posts from this blog

mongodb - Struggling to get ordered results from the last retrieved article, given array of elements to search in -

c# - Pausing a storyboard on TabItem mouse over -

c# - Attribute value in root node of xml Linq to XML -