Community ForumCategory: GeneralPDFL – Attempted to read or write protected memory.
BrianKitt asked 3 weeks ago

Getting the error below, with the following code.  Not sure where to go with this, this has been working fine, we upgraded from PDFL 32 bit to PDFL 64 bit, and also form .NET 3.5  to .NET 4.6.2 and now we are seeing this error.  I’m sure the error is related to these upgrades, but not sure why.  We are definitely running in 64 bit mode.

using (var library = new Datalogics.PDFL.Library()) {
    var options = new Datalogics.PDFL.XPSConvertParams();
    using (var document = new Datalogics.PDFL.Document(tempFilePath, options)) {
        document.Save(Datalogics.PDFL.SaveFlags.Full, Path.Combine(FilePath, fileName));
    }
}

 
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Datalogics.PDFL.PDFLPINVOKE.new_Document__SWIG_3(String jarg1, HandleRef jarg2)
   at Datalogics.PDFL.Document..ctor(String XPSFilename, XPSConvertParams ConversionParams)
   at UcmBs1367_ServerSide_BatchLetterPrinter.Program.SaveAsPDF(FixedDocument doc, Int32 iteration, DateTime printDate)
   at UcmBs1367_ServerSide_BatchLetterPrinter.Program.CreateLetter(Object data)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart(Object obj)

Datalogics Support Staff replied 2 weeks ago

Is this an environment issue, none of he 64 bit samples run? Or is the problem specific to this job? We have seen this error appear when someone is missing libraries or using the wrong ones. Have you double checked your path?

4 Answers
BrianKitt answered 2 weeks ago

Ok.  I’ve tried a number of things:
A different program accessing PDFL appears to run fine.  So it’s doing it from this flow only.
I checked for all 32 bit programs, and could not find any.
What else might be causing this?

Datalogics Support Staff answered 2 weeks ago

What version of APDFL is failing? Is the different program using the same APDFL version (if not what version is it)?
What version of APDFL is the working 32 bit version using?
If you are not using the current APDFL version I suggest testing with a current release. 

BrianKitt answered 2 weeks ago

System.BadImageFormatException: Could not load file or assembly ‘Datalogics.PDFL, Version=2.2.4745.31443, Culture=neutral, PublicKeyToken=ec84850197728341’ or one of its dependencies. An attempt was made to load a program with an incorrect format.
 
It works in some places, not others.  I’m trying to figure out whats different, but it’s been difficult due to other commitments.
Anything you could give me to narrow down the places to look is greatly appreciated.

I know the ‘bad image format’ is almost always caused by a mix of 32 bit and 64 bit.  Our app is compiled ‘Any CPU’, and we do not have ‘prefer 32 bit’ checked.

Datalogics Support Staff answered 1 week ago

Make sure your project platform is set specifically to x64 (using “Any CPU” will not work).

If using Java or .Net check the following guide
http://dev.datalogics.com/adobe-pdf-library/installing-the-software/required-components-java-and-net-applications/

BrianKitt replied 1 week ago

Ahh! That’s the problem! I have them compiled in Any CPU!!!

Thanks!!! That’s been super helpful!

Top