The process cannot access the file because it is being used by another process

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF PrintManager for .NET (v2)  /  Re: The process cannot access the file because it is being used by another process

DynamicPDF PrintManager for .NET (v2) Forum

After I print pdf:
PrintJob printJob = new PrintJob(printerName, filepath);
printJob.Print();

I call:
File.Move(filepath, archiveFilePath);

It give me the following error:
"The process cannot access the file because it is being used by another process."

Any help?

Posted by a ceTe Software moderator
Hello,

Here is a sample code that shows how to use a PDF and dispose it after printing. Disposing the InputPdf after the call to Print() method will release the file handle on the actual file. 

        // Create a print job
        PrintJob printJob = new PrintJob("PrinterName");

        // Create an InputPdf object to hold the source PDF
        InputPdf inputPdf = new InputPdf(@"C:\MyDocument.pdf", "password");

        // Add the InputPdf's pages to the print job
        printJob.Pages.Add(inputPdf);

        // Print the job
        printJob.Print();

       // Dispose InputPDF
       inputPdf.Dispose();

Thanks,
ceTe Software Support Team.
 Aug 31 2017 9:11 AM
Hi, I am getting this error while printing pdf file.
please help me.

Error:
ceTe.DynamicPDF.Printing.PrintFailedException: An error occurred while printing the document's pages. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at a(e* , Void* , Int32 , Int32 , Int32 , Int32 , Int32 , Int32 )
   at ceTe.DynamicPDF.Printing.InputPdf.a(e* , Void* , Int32 , Int32 , Int32 , Int32 , Int32 , Int32 , Boolean )
   at ceTe.DynamicPDF.Printing.ActualSizePageScaling.a(PrintJobPage , Int32 , Int32 )
   at ceTe.DynamicPDF.Printing.ActualSizePageScaling.z(PrintJobPage )
   at ceTe.DynamicPDF.Printing.PrintJobPage.i()
   at ceTe.DynamicPDF.Printing.PrintJobPageList.a()
   at ceTe.DynamicPDF.Printing.PrintJob.Print()
   --- End of inner exception stack trace ---
   at ceTe.DynamicPDF.Printing.PrintJob.Print()
Posted by a ceTe Software moderator
Hello,

Can you please send over the following details to support@cete.com so we can look into it further?

1. Sample code without dependencies that we can run on our end to recreate the issue.
2. Does the error happen with specific PDF(s)? If yes, please provide some sample PDFs.
3. Exact version and build number of the DynamicPDF PrintManager for .NET product DLL file. You can get this information in DLL references properties (Version field) in Visual Studio.
4. Operating system details: Name, x86 or x64.
5. Does the error happen when printing to specific printer(s)?.If you have not tried then please try printing to some other printer and let us know the results.
6. Are you printing to a network printer using a UNC path \\servername\\printername or a locally installed printer?
7. Printer details: Name, exact version of the printer driver.
8. Full error message along with stack trace.

Thanks,
ceTe Software Support Team.
Found a similar issue today.

SendDocument exception Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at a(Void* , UInt32 , UInt32 , Byte* , UInt32 )
at ceTe.DynamicPDF.Printing.PrintJob.Print()

Is this resolved? if so what was the fix or recomendation?
Posted by a ceTe Software moderator
Hi,

Please try using the latest version of DynamicPDF PrintManager on your end and see if it helps. You can download the latest from NuGet (Package ID: ceTe.DynamicPDF.Printing.NET) or from our website here.

Also, you can find the version notes on our website here.

If you continue to face an issue even after using the latest, then please send over following information to support@dynamicpdf.com so we can look into it further.

1. Code sample which uses static data to recreate the error.
2. Full error message along with stack trace(including error code).
3. Try printing on some other printer and let us know the results.
4. Sample PDF using which you are getting error.

Thanks,
ceTe Software support Team

All times are US Eastern Standard time. The time now is 4:29 PM.