POST
|
I recently moved my C# .NET project from a Windows 7 box (x64) to an older Windows XP box (32-bit) and have since started receiving the following error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Here's a condensed code snippet: IGeoProcessor2 gp = new GeoProcessorClass();
gp.SetEnvironmentValue("workspace", gdbLocation);
IVariantArray analysisParameters = new VarArrayClass();
[...add parameter values to array...]
gp.Execute("Pm1", analysisParameters, null); Looking through the forums reveals a wide range of potential issues. One helpful suggestion was to do garbage collection before the offending call, so I modified my code to this: IGeoProcessor2 gp = new GeoProcessorClass();
gp.SetEnvironmentValue("workspace", gdbLocation);
IVariantArray analysisParameters = new VarArrayClass();
[...add parameter values to array...]
GC.Collect();
GC.WaitForPendingFinalizers();
gp.Execute("Pm1", analysisParameters, null); Now I am getting a COM error on GC.WaitForPendingFinalizers(). The message reads: An exception was caught but handled while releasing a COM interface pointer through Marshal.Release or Marshal.ReleaseComObject or implicitly after the corresponding RuntimeCallableWrapper was garbage collected. This is the result of a user refcount error or other problem with a COM object's Release. Make sure refcounts are managed properly. The COM interface pointer's original vtable pointer was 0x1b8d9110. While these types of exceptions are caught by the CLR, they can still lead to corruption and data loss so if possible the issue causing the exception should be addressed I am not familiar enough with the inner workings of COM to be able to troubleshoot this issue any further. What exactly is the error saying? It appears that the base issue is related to the interoperation of .NET and COM, which is out of my control. What can I do to circumvent this problem?
... View more
08-22-2012
01:22 PM
|
0
|
2
|
4610
|
POST
|
Can anyone point me to an example that uses the BringForward method of IGraphicsContainer? I've searched high and low and haven't seen anything. I've tried looping through all elements, selecting the mapframe that I want with IGraphicsContainerSelect and then submitting SelectedElements in the BringForward call but that doesn't seem to do anything.
... View more
03-06-2012
08:26 AM
|
0
|
1
|
836
|
POST
|
I'm trying to add a new map frame (and accompanying map) to my document's page layout. I'm roughly following the code example from this ESRI example but the process errors out with Value does not fall within the expected range Here is the relevant code //create the new map with settings IMap addMap = new Map(); addMap = m_maps.Create(); addMap.Name = scenarioName; IEnvelope mapExtent = new EnvelopeClass(); mapExtent = (IEnvelope)m_doc.ActiveView.Extent; //create new mapframe and set map layout IMapFrame addMapFrame = new MapFrameClass(); addMapFrame.Map = addMap; IElement mapFrameElement = (IElement)addMapFrame; IGraphicsContainer pGC = (IGraphicsContainer)m_doc.PageLayout; pGC.AddElement(mapFrameElement, 0); It looks like the AddElement method doesn't like the integer being passed. I've tried with different int values but still get the same error. What could be causing this error?
... View more
03-05-2012
08:00 AM
|
0
|
1
|
1614
|
POST
|
If the selected element is one of the layers, the dataframe with the selected layer stays expanded. Ahh, there's the issue. I have a layer selected in the data frame that is not collapsing. Wouldn't it be nice for that information to be included in the documentation... Is there an easy way to unselect any selected layers in the TOC? I tried the following but it doesn't work. private void expandScenario(string scenarioName) { //collapse all data frames for (int i = 0; i < m_maps.Count; i++) { IGraphicsContainerSelect graphics = (IGraphicsContainerSelect)m_maps.Item; graphics.UnselectAllElements(); m_maps.Item.Expanded = false; } //expand the scenario's data frame for (int i = 0; i < m_maps.Count; i++) { if (m_maps.Item.Name == scenarioName) { m_maps.Item.Expanded = true; } } activateDataFrame(scenarioName); }
... View more
02-29-2012
11:09 AM
|
0
|
0
|
293
|
POST
|
I'm having an issue with using Arcobjects to expand/collapse maps (data frames) in the TOC based on a selected value in a combo box. When a user changes the selection in the combo box, all maps should collapse except for the map that shares a name with the selected combo box. This works well with 1 or 2 maps in the document. With each additional map beyond 2, the last map added does not collapse. For example, assume 2 maps - Map A and Map B. Expand collapse works well. If I add Map C and change the combo box to "Map A", only Map B collapses. If I add Map D and then change the combo box to "Map B", all maps collapse except Maps B and D. private void expandScenario(string scenarioName) { //collapse all data frames for (int i = 0; i < m_maps.Count; i++) { m_maps.Item.Expanded = false; } //expand the scenario's data frame for (int i = 0; i < m_maps.Count; i++) { if (m_maps.Item.Name == scenarioName) { m_maps.Item.Expanded = true; } } activateDataFrame(scenarioName); } I have ensured that the document is being updated via IMxDocument.UpdateContents() after making the call. I've checked to make sure the m_maps.Count accurately reflects the number of data frames. I have also checked to make sure m_maps.Item.Expanded = false is being run on the data frame that fails to collapse. I have noticed that the data frame in question collapses immediately if I move its position in the TOC - perhaps I need to refresh the TOC but I thought calling IMxDocument.UpdateContents() took care of that.
... View more
02-29-2012
09:45 AM
|
0
|
5
|
1961
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|