1

This issue affects both my VB.NET and C# Winform applications. When closing Form containing Adobe PDF Viewer conreol, the Form takex some 10 seconds to close. I tracked the issue down to Dispose method. Normally, in C# all it takes it so steal focus from Adobe PDF Control by adding lines to FormClosing event handler but in VB.NET, even if I steal focus, it still takes way too long for the Form to close. I tried to explicitly dispose the control and Implicitly - by disposing the containing Form. I tried empty string in LoadFile() method. I tried new reference to new interop library. Nothing works. Also, if you would suggest a different API/library to replace AxAcroPDFlib I'd love to read what you use.

ArtK
  • 1,157
  • 5
  • 17
  • 31
  • Have the same problem (c#. net). Fast fix is to us older version ( https://helpx.adobe.com/acrobat/kb/install-reader-x-windows.html ). If you find out something pleas update this post. – Didzis Stivriņš Jan 18 '17 at 13:05
  • Moving focus to a different control on the closing event was working in our VB.NET app until a few days ago. We received an update to Adobe and are seeing the delay again. Haven't found a solution yet. I'm going to be moving to a different control at some point but hoping to find a workaround for this for now. – Terry Jan 18 '17 at 14:16

1 Answers1

1

I now have a solution. Early testing is promising. In short, add Controls.Remove(yourPdfViewerControl) to FormClosing event handler. Of course this will offer instant alleviation of the problem but may cause memory leak. After you have removed the control from Container you could assugn null to its memory address and hope that memory manager will do its job.

So in order to prevent the leak, I created a class holding one memory space for PdfViewer control. If a Form needs a viewer, it requests it from an object that is accessible from any form to prevent memory leaks. To avoid Dispose method invocation when Form closes, make sure you remove this Control from Controls container. I can provide sample code if needed.

ArtK
  • 1,157
  • 5
  • 17
  • 31