Select to view content in your preferred language

IUniqueValueRenderer.AddReferenceValue Causes program to exit with error

561
1
Jump to solution
05-13-2013 08:56 AM
DonnaDegner
Emerging Contributor
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.
0 Kudos
1 Solution

Accepted Solutions
DonnaDegner
Emerging Contributor
I have solved this issue after a couple of weeks of working around in it to find it to be a simple solution.  When Using the addreferencevalue(New Reference Value, Value), the "Value" must be the first in the value list of the symbology tab of the layer properties.  Somehow, the data set that I was working with had a reference value saved in front of the value, so when trying to add a new reference value to an existing symbology set, it couldn't find the value that the program was referring too, though it didn't throw an error at that time.

View solution in original post

0 Kudos
1 Reply
DonnaDegner
Emerging Contributor
I have solved this issue after a couple of weeks of working around in it to find it to be a simple solution.  When Using the addreferencevalue(New Reference Value, Value), the "Value" must be the first in the value list of the symbology tab of the layer properties.  Somehow, the data set that I was working with had a reference value saved in front of the value, so when trying to add a new reference value to an existing symbology set, it couldn't find the value that the program was referring too, though it didn't throw an error at that time.
0 Kudos