We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

BarcodeBuilder.GenerateBarcodeImage Access Violation Exception

I am getting the error

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

when I call the Apsose.Barcode.BarcodeBuilder.GenerateBarcodeImage method. Are you aware of this issue and does your upcoming release address it?

Thank you,


Dear Emeka,

Thanks for your information.

Could you please share your code with us for the debugging?

We have not never get such issue before. Please post your code, we will try to repoduce the problem and fix it ASAP.

Have a good day.

Here is my code. What is interesting about the problem is that if I execute the same code in another ASP .Net application or WinForm application it works just fine or at least I do not get the exception. However there is one application in particular where I seem to get the exception repeatedly. Some times it works but fails most of the time. I even tried calling the same code in the ASP .Net Application_Startup before any of my application code gets executed to try isolating the problem but still got the same results. It is becoming a fairly urgent matter. Any help you can provide will be appreciated.



Aspose.BarCode.BarCodeBuilder bb = new Aspose.BarCode.BarCodeBuilder();

bb.SymbologyType = Aspose.BarCode.Symbology.Code39Standard;

bb.GraphicsUnit = System.Drawing.GraphicsUnit.Pixel;

bb.WideNarrowRatio = 3.0f;

bb.BarHeight = 200.0f;

bb.CodeLocation = Aspose.BarCode.CodeLocation.Below;

bb.CodeTextAlignment = System.Drawing.StringAlignment.Near;

bb.CaptionAbove = new Aspose.BarCode.Caption("");

bb.CodeText = barcode_value;

bb.Resolution = new Aspose.BarCode.Resolution(200, 200, Aspose.BarCode.ResolutionMode.Printer);

System.Drawing.Image image = bb.GenerateBarCodeImage();


Thank you for your post!

I've tested the code posted above and unable to reproduce the problem. Could you give me some code text samples ( the value of barcode_value )? And could you please post the exception call stack? ( Exception.ToString() will do ).

And does this exception always occur, or happen occassionally?

Best regards.

barcode_value is simply a string generated from System.GUID.NewGuid().ToString('N");

I think may have worked once or twice when I tried not setting some properties of the BarcodeBuilder object but I could not diplicate the coimbination of settings that made it work. All in all I get the exception every time. My guess is that memory is being currupted some where in the call to GenerateBarcodeImage(). If it is of any help, I had searched the problem in the Aspose.Word forum and found a similar issue which the Aspose.Word support team attributed to the code being generated by the XenoCode obfuscator.

"System.AccessViolationException: Attempted to read or write protected memory.
This is often an indication that other memory is corrupt.\r\n at Aspose.BarCode.BarCodeBuilder.x479874c8b70eab1e()\r\n
at Aspose.BarCode.BarCodeBuilder.x3f05e8a79ad985e2()\r\n at Aspose.BarCode.BarCodeBuilder.xd6b4fff0126b3dcb()\r\n
at Ctc.ApplicationCentral.Imaging.Barcoding.AsposeProvider.ProviderBase.CreateBarcodeImage(BarcodeFormats format, String barcode_value)\r\n at Ctc.ApplicationCentral.Subscriber.Process.Document.Policies.CreateFaxbackRequestBase.OnExecute()
in D:\\Vault\\v0101\\Subscriber\\Process\\Document\\Policies\\CreateFaxbackRequest.cs:line 157" string


Thank you for your post!

1. Are you using the latest release of Aspose.BarCode? If not, could you give it a try?

2. Are you running that sample under .Net 2.0 or .Net1.x? or Compact framework? I suspect there could be a security related problem. Check out if the windows account you are using is a restricted one, or run a anti-virus test. Use a clean machine to run the sample if possible.

Please let me know if this help.

Best regards.

I am having the exact same issue.

Running on Windows 2003 IIS6 64bit 2.0 framework

Ruinning under the Network Service account.

Here is the whole event error:

Event Type: Warning
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1309
Date: 7/18/2007
Time: 9:57:54 AM
User: N/A
Computer: XWEB01
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 7/18/2007 9:57:54 AM
Event time (UTC): 7/18/2007 2:57:54 PM
Event ID: c375894b926347b89cba098dd5bc375e
Event sequence: 4
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/1/Root/OneStop-2-128292442732812500
Trust level: Full
Application Virtual Path: /OneStop
Application Path: c:\inetpub\wwwroot\OneStop\
Machine name: XWEB01

Process information:
Process ID: 4876
Process name: w3wp.exe

Exception information:
Exception type: AccessViolationException
Exception message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Request information:

Request URL:

Request path: /OneStop/Paperwork.aspx
User host address:
Is authenticated: False
Authentication Type:

Thread information:
Thread ID: 6
Is impersonating: False
Stack trace: at Aspose.BarCode.BarCodeBuilder.x479874c8b70eab1e()
at Aspose.BarCode.BarCodeBuilder.x3f05e8a79ad985e2()
at Aspose.BarCode.BarCodeBuilder.xd6b4fff0126b3dcb()
at Aspose.BarCode.Web.UI.BarCodeWebControl.Render(HtmlTextWriter output)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Custom event details:

For more information, see Help and Support Center at https://support.microsoft.com/.

I am using the latest component ( and I'm using .Net 2.0. The probel I was having was that I kept getting the exception only in one particular application. The same code executed just fine in other sample/test applications.

I finally did find a solution that worked. Since the code will work in other programs/assemblies I decided to move my Barcode generation code from the assembly it was implemented in, to a newly created assembly and it worked. Perhaps the previous assembly'd build settings was corrupt. Anyway, since the move I have yet to experience the problem.

Thanks for your help.


I still have this problem.

Application assembly works on 32bit version of 2.0 in IIS6, but has above error in 64bit version.

Hello everyone,

Here’s a debug build of Aspose.BarCode, each line of code from Aspose.BarCode.BarCodeBuilder.x479874c8b70eab1e() is now followed by a debug output statement:


Could you please try out this build and post your output window’s debug informations? By that we can located which line of code threw out that exception.

Kindest regards.

The debug versions works fine. So I went back to the regular build and same error.

Anything different with this debug build?

What else can I try?


Thank you for your quick response!

This debug build was processed with the latest Xeno obfuscator, and was processed using previous versions. We will make a hotfix release shortly then.

Best regards.

When would you estimate the hotfix will be ready?


Thank you for your post!

Please try the latest version of Aspose.BarCode.

Best regards.

I have same problem in Aspose.Word when generate the document. It is working fine in 32bit version of Window 2003 but it throws the Access Violation Exception when i excute the application in II6 and 64bit

Can u help me ASAP?