views:

285

answers:

1

I have the binary for several pdf files stored in a collection of Byte arrays.

My goal is to concatenate them into a single .pdf file using abcpdf, then stream that newly created file to the Response object on a page of an ASP.Net website.

Had been doing it like this:

BEGIN LOOP ...

'Create a new Doc
Dim doc As Doc = New Doc

'Read the binary of the current PDF
doc.Read(bytes)

'Append to the master merged PDF doc
_mergedPDFDoc.Append(Doc)

END LOOP

Which was working fine 95% of the time. Every now and then however, creating a new Doc object would throw a System.ExecutionEngineException and crash the CLR. It didn't seem to be related to a large number of pdfs (sometimes would happen w/ only 2), or with large sized pdfs. It seemed almost completely random.

This is a known bug in abcpdf described (not very well) here Item 6.24. I came across a helpful SO post which suggested using a Using block for the abcpdf Doc object.

So now I'm doing this:

    Using doc As New Doc
        'Read the binary of the current PDF
        doc.Read(bytes)
        'Append to the master merged PDF doc
        _mergedPDFDoc.Append(doc)
    End Using

And I haven't seen the problem occur again yet, and have been pounding on a test version as best as I can to get it to.

Has anyone had any similar experience with this error? Did this fix it?

+3  A: 

ExecutionEngineExceptions are thrown when there is an internal error in the CLR, so this is one for Microsoft to fix.

Wrapping code in a using or try-catch block is therefore unlikely to work.

The issue mentioned on webSupergoo's website related to .NET 3.5 SP1, and how security attributes were applied to an assembly. I've observed this fault occurs while debugging web pages and suspect the issue is also connected to ASP.NET dynamic compilation.

ABCpdf version 7.010 and later work-around the problem. Apologies for a silly question, but did you try the latest version?

You can check which version of ABCpdf is currently installed by using the PDFSettings utility, located via Windows Start menu > Programs > ABCpdf 7.0 .NET

If updating ABCpdf is not an option then you may need to consider uninstalling .NET 3.5 SP1.

AffineMesh94464
Thanks for the response. I did see the item on the webSupergoo website. Unfortunately, I have no control over upgrading. Oddly enough, still haven't seen the problem recur, though I agree with you that there is no REASON that the using block should help. I guess it's just gotten lucky?
Tom Tresansky