470,833 Members | 1,377 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

Windows Application Build Mode?

WB
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.
Apr 26 '06 #1
2 2625
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.

"Vadym Stetsyak" wrote:
Hello, WB!

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

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

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

How do you handle PDF merge? I suppose you use some P/Invoke?
Take a look at
( http://dotnetdebug.blogspot.com/2006...ed-issues.html )

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

Apr 27 '06 #2
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
Apr 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Brad Burke | last post: by
3 posts views Thread by Jeremy S. | last post: by
5 posts views Thread by JM | last post: by
1 post views Thread by inungh | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.