.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Instanciating AcMapLayer object causes exception with FDO layers

0 REPLIES 0
Reply
Message 1 of 1
creid
314 Views, 0 Replies

Instanciating AcMapLayer object causes exception with FDO layers

Hello!

 

This was working in Map3D 2012 (I cannot test it myself, but so I have been told...) but causes excpetion in 2013 & 2014.

 

Here is my snippet:

 

   FDOLayer[] activeLayers = fdoConnection.GetActiveLayers();
   if (activeLayers.Length > 0)
   {
      foreach (FDOLayer activeLayer in activeLayers)
      {
         if (IsLayerFileInMap(activeLayer) == false)
         {
            AddLayerFromFile(activeLayer, filterLocationWKT, filterLocationType);
         }
         else if (AcMapMap.GetCurrentMap().GetLayers().Contains(activeLayer.LayerDisplayName))
         {
            AcMapLayer mapLayer = AcMapMap.GetCurrentMap().GetLayers().GetItem(activeLayer.LayerDisplayName) as AcMapLayer;
            SetLayerGeometryFilter(mapLayer, filterLocationWKT, filterLocationType);
         }
       }
    }

 

So this is how my AcMapLayer object is instanciated:

AcMapLayer mapLayer = AcMapMap.GetCurrentMap().GetLayers().GetItem(activeLayer.LayerDisplayName) as AcMapLayer;

After instanciation, when I inspect my object: 

Exceptions.png

 

it contains 2 exceptions:

  • 'mapLayer.CoordinateSystem' threw an exception of type 'OSGeo.MapGuide.MgInvalidOperationException'
  • 'mapLayer.EditMode' threw an exception of type 'OSGeo.MapGuide.MgNullReferenceException'

 

 

So later in my code, when I do the following:

mapLayer.ForceRefresh();

 I get an Exception:

'Null reference. The GWS layer source is invalid'

 

 

 

I am lost here!

Thank you in advance!

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost