5 Replies Latest reply on Sep 1, 2016 8:59 AM by Martin Kral

    Why does relating two ArcFM objects using ArcObjetcs fail on ArcGIS Server 10.2.1?

    Trond Aurud

      In a Server Object Extension (SOE) for ArcGIS Server 10.2.1 we get an error when relating two ArcFM-objects using ArcObjects. The problem was discovered during migration of an existing solution from ArcGIS Server 10.0 to 10.2.1.


      The sample code shown below, does the following:


      1. Connects to the database.
      2. Opens a table (GEONIS.ANLEGG2). This table is versioned and uses the ArcFM format.
      3. Opens a point feature classs (GEONIS.TP2). This feature class is versioned and uses the ArcFM format.
      4. Opens a relationship class (GEONIS.TP2_Anlegg2). This is an attributed relationship class.
      5. Starts editing
      6. Creates a new row in the table. This requires the ArcFMMapServer capability on the map server.
      7. Gets the feature with objectid=1 in the point feature class
      8. Calls IRelationshipClass::CreateRelationship to relate row and feature. This fails with the following message: “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”



      • Similar code works fine in a SOE for ArcGIS Server 10.0 and ArcFM Server 10.0
      • Running the same code in an Addin to ArcMap works fine. 
      • The code works with ArcGIS Server 10.2.1 if the table and feature class use ESRI objects instead of ArcFM Objects.
      • The error “Attempted to read or write protected memory” also occurs in step 6 if the ArcFMMapServer capability is not enabled on the map server.


      The error is reproducible in on our development environment (Windows 7) and in the customer environment (Windows Server 2008 R2 Standard, Service Pack 1). The database is upgraded to ArcFM 10.2.1. There is no autoupdaters set on the table and feature class used in the sample code.  The sample code is used in a SOE is created by using the SOAP template (from ESRI) in Visual Studio.


      Our environment

      • ArcGIS 10.2.1 for Server
      • ArcGIS 10.2.1 for Desktop
      • ArcFM Server 10.2.1a
      • ArcFM Solution Desktop 10.2.1  
      • Windows 7 and Windows Server 2008 R2 Standard, Service Pack 1 
      • Visual Studio 2012
      • Database client: Oracle (32 and 64 bit)


      Sample code (c#)  


      private void Test(IMessage reqMsg, IMessage respMsg)


          var workspace = ArcSdeWorkspaceFromFile(@"C:\Temp\Trond20150215.sde");

          var editWorkspace = (IWorkspaceEdit)workspace;

          var featureWorkspace = (IFeatureWorkspace)workspace;


          var anleggtable = featureWorkspace.OpenTable("GEONIS.ANLEGG2");

          var tpclass = featureWorkspace.OpenFeatureClass("GEONIS.TP2");

          var relationshipclass = featureWorkspace.OpenRelationshipClass("GEONIS.TP2_Anlegg2");





         // Creating a new objects works

         var anlegg = anleggtable.CreateRow();



         var tp = tpclass.GetFeature(1);



      // This fails on ArcGIS Server

         relationshipclass.CreateRelationship(tp, (IObject)anlegg);









      private static IWorkspace ArcSdeWorkspaceFromFile(String connectionFile)


          var factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");

          var workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

          return workspaceFactory.OpenFromFile(connectionFile, 0);




      Is this an error in ArcFM Server? Any help is appreciated.