I have a very odd problem when trying to convert an asp page to PDF using this code:
Code: C#
protected void ASPXToPDF1_AfterRender(object sender, EventArgs e)
{
EO.Pdf.HtmlToPdfResult result = (EO.Pdf.HtmlToPdfResult)ASPXToPDF1.Result;
string fileName = HttpContext.Current.Server.MapPath(@"~\File" + ID + ".pdf");
result.PdfDocument.Save(fileName); //<---- Exception generated here
}
I receive the error below. Here are some details:
1. It works fine on our public web server but not our development machines.
2. The file does not exists before calling Save method.
3. The file is found created after the exception is generated but it is zero bytes long
4. Using Windows 8 and Visual Studio 2012
Any help would be greatly appreciated.
Michael
System.IO.IOException was unhandled by user code
HResult=-2147024864
Message=The process cannot access the file 'C:\Dev\Projects\Ticket Commerce\2.7.0.0\NSiteTicketCommerce\NSiteTicketCommerce\File70512452-ad33-48a2-ae30-8d0775022cd5.pdf' because it is being used by another process.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at EO.Pdf.Internal.hj.b(String A_0)
at EO.Pdf.PdfDocument.Save(String fileName)
at ASP.waiverform70512452_ad33_48a2_ae30_8d0775022cd5_aspx.ASPXToPDF1_AfterRender(Object sender, EventArgs e) in c:\Dev\Projects\Ticket Commerce\2.7.0.0\NSiteTicketCommerce\NSiteTicketCommerce\WaiverForm70512452-ad33-48a2-ae30-8d0775022cd5.aspx:line 79
at EO.Web.ASPXToPDF.a(String A_0, Stream A_1)
at EO.Web.Internal.ms.a(b[] A_0)
at EO.Web.Internal.ms.a.Close()
at System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr)
at System.Web.HttpResponse.FilterOutput()
at System.Web.HttpApplication.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
InnerException: