cancel
Showing results for 
Search instead for 
Did you mean: 

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory.

0 Kudos

Hi,

I sometimes get an error using the Visual Studio tools when parsing RPT's. The error seems somewhat random.

Here's the trace. Do you have any ideas what may cause it? It always seems to come on get_FormulaForm().

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

at CrystalDecisions.ReportAppServer.DataDefModel.GroupNameFieldClass.get_FormulaForm()

at CrystalDecisions.CrystalReports.Engine.GroupNameFieldDefinition.get_FormulaName()

DellSC
Active Contributor

Can you provide some code around where you're seeing this error? What are you trying to do and what do you mean by "parsing RPT's"?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

As noted SP 30 had issues, upgrade to SP 31 and test again

Never seen them before, no idea what SDK they are using so it could be a dll conflict.

I suggest asking them for help.

In my Parameter test app look in this routine:

private void ReportObjectComboBox1_SelectedIndexChanged(object sender, EventArgs e)

And for field used in the report this one would work for you:

case "Fields used in the report":

Another good one is the case "Formula Fields": it will .Check all formulae and verrify they are working and if used in the Report.

You can get all of that info yourself rather than using a third party tool that you have no control over orr potentially causing side by side issues...

Answers (7)

Answers (7)

0 Kudos

Thanks, I'm the maintainer of those tools. I'll try it out with SP31.

Thanks!

0 Kudos

Thanks, I've added a try/catch to cover the exception. It seems to be the almost only place the SP has an error, so I wondered if it should be updated in the SP.

We're parsing Crystal reports for the Atlas BI Library, where report metadata is collected. Reports can be launch and searched, but our favorite part with the crystal parsing is that we can search for sql fields that are used inside the crystal reports.

0 Kudos

Are you wrapping the functions in a try/catch block to see if it catches the error?

And if there is no formula catch {} and ignore, see if that works. I often use .Count to process, but sometimes that function causes an error also.

0 Kudos

Thanks for the reply. The issue is with the latest Visual Studio SP, trying to get the formula for groups. If the group doesn't have a formula, the SP crashes.

0 Kudos

Hi Christopher,

Not possible, you can't convert an RPT file to xml to get the meta data of the report. RPT files are in a proprietary format.

What are you attempting to get from the report?

In CR Designer you can export to Report Definition, gives you most of the info or you can use the SDK to get vaious parts from the Report.

See my Parameter test app for more info, it's in the drop down list for the report objects.

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

Don

0 Kudos

Thanks for the questions!

1. I using SP 30 in a desktop app.

2. The app is opening crystal .rpt files and parsing them to extract metadata. The program is here: https://github.com/ajryan/RptToXml/tree/master/RptToXml

The full crash is always on FieldDefinition. Here's a trace:

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at CrystalDecisions.ReportAppServer.DataDefModel.GroupNameFieldClass.get_FormulaForm() at CrystalDecisions.CrystalReports.Engine.GroupNameFieldDefinition.get_FormulaName() at RptToXml.RptDefinitionWriter.GetFieldObject(Object fo, eportDocument report, XmlWriter writer) in C:\Users\chris-pickering\Documents\r_source\rpttoxml\RptToXml\RptDefinitionWriter.cs:line 445 at RptToXml.RptDefinitionWriter.GetDataDefinition(ReportDocument report, XmlWriter riter) in C:\Users\chris-pickering\Documents\r_source\rpttoxml\RptToXml\RptDefinitionWriter.cs:line 383 at RptToXml.RptDefinitionWriter.ProcessReport(ReportDocument report, XmlWriter writer) in C:\Users\chris-pickering\Documents\r_source\rpttoxml\RptToXml\RptDefinitionWriter.cs:line 127 at RptToXml.RptDefinitionWriter.WriteToXml(XmlWriter writer)in :\Users\chris-pickering\Documents\r_source\rpttoxml\RptToXml\RptDefinitionWriter.cs:line 71 at RptToXml.RptDefinitionWriter.WriteToXml(String targetXmlPath) in C:\Users\chris-pickering\Documents\r_source\rpttoxml\RptToXml\RptDefinitionWriter.cs:line 62 at RptToXml.Program.Main(String[] args) in C:\Users\chris-pickering\Documents\r_source\rpttoxml\RptToXml\Program.cs:line 62

3. When running on a single file (know to cause a crash), I get a crash, so I think it is not related to GC.Collect(). Also the files are opened as tempfiles so I think not the issue.

Here is a screenshot of the problem.

I tried to find the problem in the report as well, but am not sure. The crash is on finding the formula name for a group. So I right click on the group > get formula, and I get this message:

Should the "GroupNameFieldDefinition.FormulaName" return a "None" when there is no linked formula, instead of crashing? I wonder if the RPT is corrupt and there used to be a formula that is now non-existent?

Thanks for looking!

Christopher **edited to add back images.

0 Kudos

Desktop or WEB app?

What SP are you using?

Often when you get random errors it's memory related, CR requires contiguous blocks of memory.

So be sure to close the report document when it's done and sometimes adding in GC.Collect() may help Windows clean up it's own memory outside of CR stuff. Internally we do call that function.