AnsweredAssumed Answered

IUniqueValueRenderer.AddReferenceValue Causes program to exit with error

Question asked by ddegner on May 13, 2013
Latest reply on May 13, 2013 by ddegner
I am using the IUniqueValueRenderer.AddReferenceValue statement in a program to add additional values to an existing value for symbology purposes.  After the value has been added, I perform a IUniqueValueRenderer.ReferenceValue statement to check the values.  It does not show the new value as having been added although the statement executes without error.  I can do several statements afterwords that will work just fine, until I do a ZoomToWhole on the page.  At which point, the program sends an error:

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

If I remove this part of the program, don't add reference values, the program runs fine without error.  I am able to add values to the renderer and continue on.  As long as the AddReferenceValue statement is commented out, the rest of the program works.  Here is the code:

                       For i = 0 To pRender.ValueCount - 1
                            pRender.AddReferenceValue(pRow.Value(ndx), "UNCOMMITTED")
                            pMXDoc.CurrentContentsView.Refresh(pLayer)
                            pMXDoc.UpdateContents()
                            pApp.SaveDocument()
                            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pRender)
                            pRender = gLayer.Renderer
                            pMXDoc.PageLayout.ZoomToWhole()
                         Next i

As you can see from the code, I have tried all kinds of things to free whatever memory it perceives as being in use.

Outcomes