Access Violation Exception thrown
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
Access Violation Exception thrown
Hi,
I'm getting the following internal exception intermittently.
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
.XCPro40_Defs.PXCp_OptimizeFonts(Int32, Int32)
Do you know why this is happening and how to prevent it?
Thank you,
I'm getting the following internal exception intermittently.
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
.XCPro40_Defs.PXCp_OptimizeFonts(Int32, Int32)
Do you know why this is happening and how to prevent it?
Thank you,
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Access Violation Exception thrown
What language are you using? Can you provide a short code sample to show the context?
Re: Access Violation Exception thrown
I'm using VB (Framework 4.0 on VS 2010).
Try
Dim iRes As Integer
sCurrentProcess = "OptimizeFontsAfterMerge"
iRes = XCPro40_Defs.PXCp_OptimizeFonts(m_iPDF, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "OptimizeNamedDests"
iRes = XCPro40_Defs.PXCp_OptimizeRemoveNamedDests(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "MergedFileCompression"
iRes = XCPro40_Defs.PXCp_OptimizeStreamCompression(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
bNewFile = False
Return True
Catch ex As Exception
'Some handle
Return False
End Try
I even have the code within the try-catch block and yet it throws the exception and terminates the program..
Try
Dim iRes As Integer
sCurrentProcess = "OptimizeFontsAfterMerge"
iRes = XCPro40_Defs.PXCp_OptimizeFonts(m_iPDF, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "OptimizeNamedDests"
iRes = XCPro40_Defs.PXCp_OptimizeRemoveNamedDests(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "MergedFileCompression"
iRes = XCPro40_Defs.PXCp_OptimizeStreamCompression(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
bNewFile = False
Return True
Catch ex As Exception
'Some handle
Return False
End Try
I even have the code within the try-catch block and yet it throws the exception and terminates the program..
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Access Violation Exception thrown
But this is completely intermittent? ie, if you re-run it on the same inputs it will occasionally terminate but other times complete successfully? Or does it depend on the input you are using?isaware wrote:I'm using VB (Framework 4.0 on VS 2010).
Try
Dim iRes As Integer
sCurrentProcess = "OptimizeFontsAfterMerge"
iRes = XCPro40_Defs.PXCp_OptimizeFonts(m_iPDF, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "OptimizeNamedDests"
iRes = XCPro40_Defs.PXCp_OptimizeRemoveNamedDests(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "MergedFileCompression"
iRes = XCPro40_Defs.PXCp_OptimizeStreamCompression(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
bNewFile = False
Return True
Catch ex As Exception
'Some handle
Return False
End Try
I even have the code within the try-catch block and yet it throws the exception and terminates the program..
Re: Access Violation Exception thrown
It happens intermittent. With same files it happens sometimes it doesn't sometimes.
I'll explain what happens exactly.
Let say we have 15 PDF files that we want to combine 5 PDFs each so we could end up with 3 PDF files. (Running same functions 3 times in a loop)
It processes the first 5 PDFs and merge them correct. The next merge fails on the third file - it throws the error and terminates the program. Then the program restarts automatically and it runs the failed 5 PDFs again. This time it processes correct but for the next set of 5 PDFs, it fails again on the third file.
It is very weird that it always fails on the third file.
Also we have the whole function wrapped in the try-catch block and yet the program throws an unhandled exception..
I'll explain what happens exactly.
Let say we have 15 PDF files that we want to combine 5 PDFs each so we could end up with 3 PDF files. (Running same functions 3 times in a loop)
It processes the first 5 PDFs and merge them correct. The next merge fails on the third file - it throws the error and terminates the program. Then the program restarts automatically and it runs the failed 5 PDFs again. This time it processes correct but for the next set of 5 PDFs, it fails again on the third file.
It is very weird that it always fails on the third file.
Also we have the whole function wrapped in the try-catch block and yet the program throws an unhandled exception..
- Ivan - Tracker Software
- Site Admin
- Posts: 3550
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
- Contact:
Re: Access Violation Exception thrown
Can you send us complete simplest VB project using which we can try to reproduce the issue?
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Re: Access Violation Exception thrown
There is no simple sample code since it occurs on a complex windows service that ties to a lot of different functionalities. We've been using this service for more than 2 years now and the only change that happened recently is the OS that the service resides. Again, this issue occurs intermittently.
- Paul - Tracker Supp
- Site Admin
- Posts: 6901
- Joined: Wed Mar 25, 2009 10:37 pm
- Location: Chemainus, Canada
- Contact:
Re: Access Violation Exception thrown
HI isaware,
I'm sure you can appreciate that if this is difficult to reproduce then it will be exceedingly difficult to correct. Before we go any further can you confirm that this is all being done with the current build? (Build 200 is current as I write this.) There is not much point moving forward investigating older builds if this is not an issue in 200.
Also you mentioned that this became apparent after a move to a new OS.
regards
I'm sure you can appreciate that if this is difficult to reproduce then it will be exceedingly difficult to correct. Before we go any further can you confirm that this is all being done with the current build? (Build 200 is current as I write this.) There is not much point moving forward investigating older builds if this is not an issue in 200.
Also you mentioned that this became apparent after a move to a new OS.
Is this behaviour then only on a single physical machine or does this happen on more than one machine? We are wondering if there is something hardware related that may be causing this and would like to be able to eliminate this as a possible cause.We've been using this service for more than 2 years now and the only change that happened recently is the OS that the service resides. Again, this issue occurs intermittently.
regards
Best regards
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Re: Access Violation Exception thrown
I'm attaching some sample code for this issue..
Access violation error occurs usually on saving the second merge or optimize font for the second merge.
Even when the exception doesn't get thrown, the resulted file doesn't display correct..
Public Sub New(ByVal sRootFileName As String, ByVal sFirstMergeFile As String)
Dim sCurrentProcess As String = ""
Try
Dim iRes As Integer
sCurrentProcess = "InitMergeFile"
iRes = XCPro40_Defs.PXCp_Init(m_iPDF, XCPro40_Defs.g_RegKey, XCPro40_Defs.g_DevCode)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "ReadMergeFile"
iRes = XCPro40_Defs.PXCp_ReadDocumentW(m_iPDF, sFirstMergeFile, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
bHasRootFile = True
bNewFile = True
m_sRootFileName = sRootFileName
Catch ex As Exception
mCommon.LogWrite("Initialize isaPDFMerge for " & sCurrentProcess & " : " & sRootFileName & vbCrLf & ex.Message, ErrorLogType.eltPDFErrors)
bHasRootFile = False
End Try
End Sub
Public Function MergeDocument(ByVal sFileName As String) As Boolean
Dim sCurrentProcess As String = ""
Try
Dim iRes As Integer
Dim iPDFToMerge As Integer
sCurrentProcess = "InitOrgFile"
iRes = XCPro40_Defs.PXCp_Init(iPDFToMerge, XCPro40_Defs.g_RegKey, XCPro40_Defs.g_DevCode)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "ReadOrgFile"
iRes = XCPro40_Defs.PXCp_ReadDocumentW(iPDFToMerge, sFileName, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "GetPagesCount"
Dim iPagesRange() As XCPro40_Defs.PXCp_CopyPageRange
ReDim iPagesRange(1)
Dim iPagesCount As Integer
iRes = XCPro40_Defs.PXCp_GetPagesCount(iPDFToMerge, iPagesCount)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "InsertMergeFile"
iPagesRange(0).StartPage = 0
iPagesRange(0).EndPage = iPagesCount - 1
iPagesRange(0).InsertBefore = -1
XCPro40_Defs.PXCp_InsertPagesTo(iPDFToMerge, m_iPDF, iPagesRange, 1, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, XCPro40_Defs.PXCp_WriteDocFlag.PXCp_Write_NoRelease)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "ReleaseMergeFile"
iRes = XCPro40_Defs.PXCp_Delete(iPDFToMerge)
mCommon.ResultChecks(iRes, sCurrentProcess)
Return True
Catch ex As Exception
mCommon.LogWrite("MergeDocument for " & sCurrentProcess & " : " & sFileName & vbCrLf & ex.Message, ErrorLogType.eltPDFErrors)
Return False
End Try
End Function
Public Function WriteDocument() As Boolean
Dim sCurrentProcess As String = ""
Try
Dim iRes As Integer
sCurrentProcess = "OptimizeFontsAfterMerge"
iRes = XCPro40_Defs.PXCp_OptimizeFonts(m_iPDF, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "OptimizeNamedDests"
iRes = XCPro40_Defs.PXCp_OptimizeRemoveNamedDests(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "MergedFileCompression"
iRes = XCPro40_Defs.PXCp_OptimizeStreamCompression(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "ReleaseMergeFile"
iRes = XCPro40_Defs.PXCp_Delete(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
bNewFile = False
Return True
Catch ex As Exception
mCommon.LogWrite("WriteDocument for " & sCurrentProcess & vbCrLf & ex.Message, ErrorLogType.eltPDFErrors)
Return False
End Try
End Function
Public Function ReleaseFirstTime() As Boolean
Dim sCurrentProcess As String = ""
Try
Dim iRes As Integer
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, XCPro40_Defs.PXCp_WriteDocFlag.PXCp_Write_NoRelease)
mCommon.ResultChecks(iRes, sCurrentProcess)
Return True
Catch ex As Exception
mCommon.LogWrite("ReleaseFirstTime for " & sCurrentProcess & vbCrLf & ex.Message, ErrorLogType.eltPDFErrors)
Return False
End Try
End Function
Functions to create merged files.
Dim oMergePDF As isaPDFMerge = New isaPDFMerge(sMergedFileName1, sFirstFile)
oMergePDF.ReleaseFirstTime()
oMergePDF.MergeDocument(sSecondFile)
oMergePDF.MergeDocument(sThirdFile)
oMergePDF.MergeDocument(sFourthFile)
oMergePDF.MergeDocument(sFifthFile)
oMergePDF.WriteDocument()
oMergePDF = New isaPDFMerge(sMergedFileName2, sFirstFile)
oMergePDF.ReleaseFirstTime()
oMergePDF.MergeDocument(sSecondFile)
oMergePDF.MergeDocument(sThirdFile)
oMergePDF.MergeDocument(sFourthFile)
oMergePDF.MergeDocument(sFifthFile)
oMergePDF.WriteDocument()
Access violation error occurs usually on saving the second merge or optimize font for the second merge.
Even when the exception doesn't get thrown, the resulted file doesn't display correct..
Public Sub New(ByVal sRootFileName As String, ByVal sFirstMergeFile As String)
Dim sCurrentProcess As String = ""
Try
Dim iRes As Integer
sCurrentProcess = "InitMergeFile"
iRes = XCPro40_Defs.PXCp_Init(m_iPDF, XCPro40_Defs.g_RegKey, XCPro40_Defs.g_DevCode)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "ReadMergeFile"
iRes = XCPro40_Defs.PXCp_ReadDocumentW(m_iPDF, sFirstMergeFile, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
bHasRootFile = True
bNewFile = True
m_sRootFileName = sRootFileName
Catch ex As Exception
mCommon.LogWrite("Initialize isaPDFMerge for " & sCurrentProcess & " : " & sRootFileName & vbCrLf & ex.Message, ErrorLogType.eltPDFErrors)
bHasRootFile = False
End Try
End Sub
Public Function MergeDocument(ByVal sFileName As String) As Boolean
Dim sCurrentProcess As String = ""
Try
Dim iRes As Integer
Dim iPDFToMerge As Integer
sCurrentProcess = "InitOrgFile"
iRes = XCPro40_Defs.PXCp_Init(iPDFToMerge, XCPro40_Defs.g_RegKey, XCPro40_Defs.g_DevCode)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "ReadOrgFile"
iRes = XCPro40_Defs.PXCp_ReadDocumentW(iPDFToMerge, sFileName, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "GetPagesCount"
Dim iPagesRange() As XCPro40_Defs.PXCp_CopyPageRange
ReDim iPagesRange(1)
Dim iPagesCount As Integer
iRes = XCPro40_Defs.PXCp_GetPagesCount(iPDFToMerge, iPagesCount)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "InsertMergeFile"
iPagesRange(0).StartPage = 0
iPagesRange(0).EndPage = iPagesCount - 1
iPagesRange(0).InsertBefore = -1
XCPro40_Defs.PXCp_InsertPagesTo(iPDFToMerge, m_iPDF, iPagesRange, 1, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, XCPro40_Defs.PXCp_WriteDocFlag.PXCp_Write_NoRelease)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "ReleaseMergeFile"
iRes = XCPro40_Defs.PXCp_Delete(iPDFToMerge)
mCommon.ResultChecks(iRes, sCurrentProcess)
Return True
Catch ex As Exception
mCommon.LogWrite("MergeDocument for " & sCurrentProcess & " : " & sFileName & vbCrLf & ex.Message, ErrorLogType.eltPDFErrors)
Return False
End Try
End Function
Public Function WriteDocument() As Boolean
Dim sCurrentProcess As String = ""
Try
Dim iRes As Integer
sCurrentProcess = "OptimizeFontsAfterMerge"
iRes = XCPro40_Defs.PXCp_OptimizeFonts(m_iPDF, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "OptimizeNamedDests"
iRes = XCPro40_Defs.PXCp_OptimizeRemoveNamedDests(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "MergedFileCompression"
iRes = XCPro40_Defs.PXCp_OptimizeStreamCompression(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "ReleaseMergeFile"
iRes = XCPro40_Defs.PXCp_Delete(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
bNewFile = False
Return True
Catch ex As Exception
mCommon.LogWrite("WriteDocument for " & sCurrentProcess & vbCrLf & ex.Message, ErrorLogType.eltPDFErrors)
Return False
End Try
End Function
Public Function ReleaseFirstTime() As Boolean
Dim sCurrentProcess As String = ""
Try
Dim iRes As Integer
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, XCPro40_Defs.PXCp_WriteDocFlag.PXCp_Write_NoRelease)
mCommon.ResultChecks(iRes, sCurrentProcess)
Return True
Catch ex As Exception
mCommon.LogWrite("ReleaseFirstTime for " & sCurrentProcess & vbCrLf & ex.Message, ErrorLogType.eltPDFErrors)
Return False
End Try
End Function
Functions to create merged files.
Dim oMergePDF As isaPDFMerge = New isaPDFMerge(sMergedFileName1, sFirstFile)
oMergePDF.ReleaseFirstTime()
oMergePDF.MergeDocument(sSecondFile)
oMergePDF.MergeDocument(sThirdFile)
oMergePDF.MergeDocument(sFourthFile)
oMergePDF.MergeDocument(sFifthFile)
oMergePDF.WriteDocument()
oMergePDF = New isaPDFMerge(sMergedFileName2, sFirstFile)
oMergePDF.ReleaseFirstTime()
oMergePDF.MergeDocument(sSecondFile)
oMergePDF.MergeDocument(sThirdFile)
oMergePDF.MergeDocument(sFourthFile)
oMergePDF.MergeDocument(sFifthFile)
oMergePDF.WriteDocument()
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Access Violation Exception thrown
Thanks for the sample code isaware,
I've asked one of my colleagues to take a look and we will post back here as soon as we have any further comments.
Best,
Stefan
I've asked one of my colleagues to take a look and we will post back here as soon as we have any further comments.
Best,
Stefan
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Access Violation Exception thrown
Hello again isaware,
We discussed this case in the team, and we will need a complete sample (sources, executable and test files), as at first look the code you have posted looks correct but my colleague working on your case says that he is doing something differently than you (e.g. using older/newer wrappers) - and as such it would be best and fastest if you send us the full sample.
Best,
Stefan
We discussed this case in the team, and we will need a complete sample (sources, executable and test files), as at first look the code you have posted looks correct but my colleague working on your case says that he is doing something differently than you (e.g. using older/newer wrappers) - and as such it would be best and fastest if you send us the full sample.
Best,
Stefan
Re: Access Violation Exception thrown
I'm attaching the full sample code. I took out the dev/reg codes.
I also had to took out some files (including dlls) since the forum only allows maximum of 5MB.
I also had to took out some files (including dlls) since the forum only allows maximum of 5MB.
- Attachments
-
- AccessViolationException.zip
- (37.43 KiB) Downloaded 232 times
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Access Violation Exception thrown
Thanks isaware,
We will work with that and post here as soon as we have any news.
Best,
Stefan
We will work with that and post here as soon as we have any news.
Best,
Stefan
- Lzcat - Tracker Supp
- Site Admin
- Posts: 677
- Joined: Thu Jun 28, 2007 8:42 am
Re: Access Violation Exception thrown
Can you provide your test files, please?
And with detailed instruction how to use your project, please - it runs, but no error messages, no crash, nothing.
And with detailed instruction how to use your project, please - it runs, but no error messages, no crash, nothing.
Victor
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Access Violation Exception thrown
I'm also attaching the outcome files.
- Attachments
-
- testresult2_test.pdf
- (20.47 KiB) Downloaded 280 times
-
- testresult_test.pdf
- (39.8 KiB) Downloaded 377 times
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Access Violation Exception thrown
hello isaware,
Seems like Lzcat (Victor) has finished for today - but I have passed him your samples and he will follow up here as soon as possible.
Best,
Stefan
Seems like Lzcat (Victor) has finished for today - but I have passed him your samples and he will follow up here as soon as possible.
Best,
Stefan
- Lzcat - Tracker Supp
- Site Admin
- Posts: 677
- Joined: Thu Jun 28, 2007 8:42 am
Re: Access Violation Exception thrown
Thanks for files, but where I should put them?
Or where I should put breakpoint to start debugging and see where files should be located?
Or where I should put breakpoint to start debugging and see where files should be located?
Victor
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Access Violation Exception thrown
If you look at the code, I hardcoded the file on the form load event.
You can just change the file path - also the file path for the new merged PDFs - to wherever you saved the file.
You can just change the file path - also the file path for the new merged PDFs - to wherever you saved the file.
- Lzcat - Tracker Supp
- Site Admin
- Posts: 677
- Joined: Thu Jun 28, 2007 8:42 am
Re: Access Violation Exception thrown
Hi isaware.
As in most cases when using xcpro a crash is because of an incorrect call sequence:
As in most cases when using xcpro a crash is because of an incorrect call sequence:
Call to PXCp_WriteDocumentW with the last parameter 0 (zero) will release the document, and subsequent calls to the PXCp_Delete function with the same document handle will result memory corruption. This may be not a problem for a while, but the program will eventually crash (in your case - at the second write operation). The solution is to replace 0 with XCPro40_Defs.PXCp_WriteDocFlag.PXCp_Write_NoRelease (or do not call the PXCp_Delete function if the write operation was successful.Public Function WriteDocument() As Boolean
'some code skipped
sCurrentProcess = "WriteMergeFile"
iRes = XCPro40_Defs.PXCp_WriteDocumentW(m_iPDF, m_sRootFileName, XCPro40_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, 0)
mCommon.ResultChecks(iRes, sCurrentProcess)
sCurrentProcess = "ReleaseMergeFile"
iRes = XCPro40_Defs.PXCp_Delete(m_iPDF)
mCommon.ResultChecks(iRes, sCurrentProcess)
Victor
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.