5 Replies Latest reply on Apr 1, 2014 12:29 AM by danielrouleau

    ArcFM Custom Autoupdaters - Unable to Cast object of Type...-MMAutoupdaterclass

    Jim Kyle

      I came across a interesting bug the other day which I thought I would share just in case anybody else experiences it.

      Anyway, we have some custom attribute autoupdaters, which have existed since the 9.2 days of ArcFM, pretty simple in nature. (Currently at 10.0.3)

      Basically the code was essentially;
          public object GetAutoValue(IObject pObj)

               IMMAutoUpdater updater = new MMAutoUpdaterClass();

              // Do stuff


      Anyway, we found that these autoupdaters were not firing in a certain situation.  The situation was that
      on features which had autoupdaters such as ArcFM Auto Phase Assign, and if the first feature to edit in a session was one of these features,
      then the following autoupdaters would not fire because debugging revealed they received an
      Unable to cast object of type Sytem._ComObject' to type 'Miner.Interop.MMAutoUpdaterClass'.   It appears that since ArcFM Auto Phase Assign
      must be wrapping this object in a generic wrapper.
      I believe the more correct coding which fixes this problem is;
        Type type = Type.GetTypeFromProgID("mmGeodatabase.MMAutoUpdater");

         object obj = Activator.CreateInstance(type);

         ImmAutoUpdater updater = obj as IMMAutoUpdater;


      Would it be safe to assume that if we have any custom code out there that uses '... = new MMAutoUpdaterClass();' that we should
      carefully review that code and possibly modify it?

      I believe we are forced to in a subsequent release;  Solution - ArcFM - MMAutoUpdaterClass no longer in ArcFM 10.1 API