Print Page | Close Window

Attempted to read or write protected

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1432
Printed Date: 27 Jun 25 at 9:33AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Attempted to read or write protected
Posted By: rgoodson
Subject: Attempted to read or write protected
Date Posted: 02 May 10 at 1:58AM
Hello,
 
I am using Visual Basic 2008 and the QuickPDFDLL0718.dll file to develop my application. I have added the QuickPDFDLL0718.dll file to my application's directory as well as add the file QuickPDFDLL0718.vb to my application. The methods work correctly, however I keep getting the error message "Attempted to read or write protected memory" every time I call the quick pdf methods. I have created a very small sample application that demonstrates the problem.
 
Is there somewhere that I can email that application to you so that you can take a look at it for me?
 
I really appreciate your help.
 
Reagan



Replies:
Posted By: Ingo
Date Posted: 02 May 10 at 10:15AM
Hi Reagan!

This is not a real QuickPDF-problem...
more a dll-.NET-problem.
You should google with the error string...
If you want to upload it here you can use the official support pages:
http://www.quickpdflibrary.com/

Cheers, Ingo




Posted By: rgoodson
Date Posted: 02 May 10 at 11:47AM

Actually, I have googled the error and it says that it is an error that can occur when your are using non-managed code within managed code, which is exactly what is going on with the QuickPDF dll, since it is not a .Net assembly. I never get the problem until I call the QuickPDF code, and then it occurs every time.

Also, when I run the compiled version of the sample app I get an unhandled exception saying ""Value cannot be null. Parameter name: ptr" and then it goes on to reference some information about the QuickPDF dll. I can give you that application as well.
 
It appears that there is some kind of memory leak within the QuickPDF dll file. I just want somebody to please take a look at it, since I have paid for the QuickPDF tool but am unable to use it due to this error. Its very frustrating because the support guy "Rowan" will not respond to my request, even though I have spent hours working to narrow down this error as much as I possibly can.
 
I would appreciate any help that you can provide me.
 
Thanks,
Reagan


Posted By: Ingo
Date Posted: 02 May 10 at 12:00PM
Hi Reagan!

It's not the best calling unmanaged code from managed code but you can do it.
You should read further (and deeper)  on the msdn-pages. There's a lot of stuff regarding this fact.
"Value cannot be null" ... it seems that an object should be called but it wasn't already created 'cause some things are missing.
Please read here:
http://www.quickpdflibrary.com/help/getting-started.php
There you will find all about how to call a dll and how to do this with .NET...
If there are still problems AFTER this you should post/upload your stuff on the official support pages.
This here is only a user-user-forum (you should know this already) and i'm only a user, too.
With "DLLImport" and the Marshal-syntax your problem should be solved. Give Google a try.

Cheers, Ingo   


Posted By: johnr
Date Posted: 11 Aug 10 at 10:05PM
Ah ha! I ran into the exact same problem just today.
 
Yet I have an additional observation:
 
Running vb dotnet 2010, I've successfully used the same dll method you are using to use quick pdf in the vb dotnet environment without running into the memory error for weeks, in loops that call the dll hundreds of times.
 
I did this by simply tweaking the sample vb .net application, no issues.
 
Today was the first time I tried adding the dll to an existing vb application, updating the dll path and copying that dll to my program directory, and started getting the same memory message from 5 to 30 seconds after the first time I call upon the quick pdf dll.
 
I haven't yet examined the differences, but I suspect you can work around your problem by downloading and modifying the sample vb dll project to meet your needs. (let us know if you can confirm this).
 
It's all I have at the moment, but you're not alone in getting that memory message.


Posted By: that0th3rGuy
Date Posted: 02 Nov 10 at 2:34PM
Hi there,

So, considering that I'm replying to this thread, you can assume that I'm having a similar problem.

We collect utility usage data from various meters in the field and store it in our database. From the database we generate itemized bills for our clients in PDF format. The PDF document also has a logo and two graphs (all of these using the pdfDoc.DrawImage() function).

The thing I find a little funny is that I get the error on every second generated document - the first document generates, and then the second one fails. So what I did (as a temporary solution) I added a loop that attempt to generate the document again when it fails (up to a maximum of 5 retries) and when popping a message box with the number of retries I get '2' every time (the loop is effective in that it works every time now, but it's not ideal at all). It's almost like the occurrence of the exception is clearing that which is causing the exception in the first place. As far as I can tell I get the error at the first call to any QuickPDF dll function after the first document has been generated - last Stack trace entry: at QuickPDFDLL0716.DLL.DelegateIII.Invoke(Int32 P1, Int32 P2).

I'm not saying it's the QuickPDF dll that's causing the problem; heck, I wouldn't be surprised if I'm doing something wrong. I would just like to know if there is any way to solve this.

Thanx in advance to anyone and everyone for all the time and effort in trying to assist me in this matter.

Best regards,
me


Posted By: that0th3rGuy
Date Posted: 03 Nov 10 at 9:02AM
For what it's worth, my problem has been solved. I'm not sure if it's the most efficient, but it works, and I'm relieved.

I don't know where exactly or what exactly the problem was, but calling GC.Collect() to force collection after generating each document cleared up the issue.

Hope this helps.

Cheers.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk