Windows Application Build Mode?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a C# Windows application that reads a bunch of PDF files and append
them together. Basically it does it by reading a first 2 PDF files, append
them and save the result as a PDF file. Then append the 3rd PDF to this
result and save. Then the 4th one and save and so on... In total it can be
appending up to 50 PDF files, each with file size ranges between 10 to over
50MB.

It runs fine when it's built in Debug mode. But when it's built in Release
mode, it will not be able to handle appending of large number of big size
files. It gives the following error in the line when it tries to save.

System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.

And it doesn't fail at a consistent point. Sometimes it fails on the 10th
file, sometimes after 35 files, even when tested against the same set of
files. However, when tested on a smaller set of small size PDF files, it
won't give a problem.

At first I thought it's something wrong with my multi-threading, so now I
just run everything in a single thread but it's still the same.

I don't intend to put my codes here 'cuz it's too long and there are many
classes etc. Instead, I'd just like to ask a general question -- what's the
difference between a program compiled in Release and Debug mode that can
contribute to this error?

My understanding is that building in Release mode optimizes the performance
and disables all Debug class methods but I don't see how these are related to
my problem.

Thanks,
WB.
 
Hi,

We use a 3rd party software call ABCpdf to handle that. Basically the code
is something like this:

Doc theDoc1 = new Doc();
theDoc1.Read("C:\\file1.pdf");
Doc theDoc2 = new Doc();
theDoc2.Read("C:\\file2.pdf");
theDoc1.Append(theDoc2);
theDoc1.Save("C:\\output.pdf");
theDoc1.Dispose();
theDoc2.Dispose();

Doc() is a class from the software...

What's P/Invoke?


WB.
 
Hello, WB!

W> We use a 3rd party software call ABCpdf to handle that. Basically the
W> code is something like this:

W> Doc theDoc1 = new Doc();
W> theDoc1.Read("C:\\file1.pdf");
W> Doc theDoc2 = new Doc();
W> theDoc2.Read("C:\\file2.pdf");
W> theDoc1.Append(theDoc2);
W> theDoc1.Save("C:\\output.pdf");
W> theDoc1.Dispose();
W> theDoc2.Dispose();

W> Doc() is a class from the software...

It looks like on the bug in that software...

W> What's P/Invoke?

It is called Platform Invoke and it is used to call unmanaged functions.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Back
Top