0

I have developed one application which generate documents using microsoft.Office.Interop.Word.

I'm facing some problems here.
Document generation process is not working on windows server 2012 R2.

After long search over internet somehow it is working now. But the problem is if my site is in idle mode for approx 8 hours and after that if I try to do same process of generation of documents, it won't work.

But, after restarting my application pool on IIS, it works again.

Anybody have idea what is going on?
Thank you.

Pranav Patel
  • 1,541
  • 14
  • 28
  • I found with interop stuff if when done you dont ensure ALL items are now null, even the garbage collector doesnt revert them and you end up with many instances of in your case word left open.. once you have too many it can go wonky.. Even if the app ends, they remain - so the same would be true for web.. – BugFinder Feb 14 '17 at 08:23
  • Probably after 8 hours the app pool is unloaded and there is no w3wp process; then the user you're running as is not logged in and it can't run your code. Of course, any exception info would help. – zaitsman Feb 14 '17 at 08:27
  • @zaitsman I have tried to get error info but unable to find any single trace or clue. If there is no w3wp process then it would not even run the site but it run perfectly with all DB functionality only documentation part is not working. – Pranav Patel Feb 14 '17 at 08:41
  • @BugFinder you are right but in this case after restarting the application pool it should not work but NO, after restating application pool it again work perfect until it become idle for next approx 8 hours. – Pranav Patel Feb 14 '17 at 08:43
  • when its grumpy, are there absolutely no errors? no processes on the server that look out of place? – BugFinder Feb 14 '17 at 08:44
  • @BugFinder No error even I have checked process under task manager if any WORD related process is going on and checked IIS trace log and windows log but could not found any single error. – Pranav Patel Feb 14 '17 at 08:46
  • what logging did you add to your code? can you put that function in a basic `try` `catch`? – zaitsman Feb 14 '17 at 09:22
  • I have put try catch as well in application_error but no luck.. @zaitsman – Pranav Patel Feb 14 '17 at 11:40

1 Answers1

0

Don't do office interop in a web application, Microsoft does not recommend it either. Use other libraries (NPOI, Aspose,...) some are free, some are commercial.

BennyM
  • 2,796
  • 16
  • 24
  • You are right but I'm developing in project which is older and almost not possible to change code from all modules. @Benny – Pranav Patel Feb 14 '17 at 08:39