I am dynamically creating a join between a GeoFeatureLayer and an external ITable derived from a SQL query and opened with OpenQueryClass(). It works. Now if I could only delete the Join!? But even worse than that: when I re-enter the code that creates a new join (after I run some code that seems to remove the existing joined fields from the GeoFeatureLayer) it fails to create the ITable the 2nd time because "The FeatureClass already exists." So it appears that not only must I reset the GeoFeatureLayer I must also remove the named ITable. Is this correct? If so, how?

  • Does this thread help at all? gis.stackexchange.com/questions/11088/…
    – blah238
    Oct 21, 2011 at 22:52
  • I'm running some of that code to remove the join but nothing in that code addresses the issue with the named ITable I'm creating from SQL. The removal runs, it appears to work (I'm not going to allow multiple joins) and then the code goes to create a new join and runs into the OpenQueryClass() call and fails because "The Feature Class already exists." I can randomize the name with a Guid and it will all work but I worry that the orphaned table is a "bad thing" that will never go away until no memory is left.
    – Chaz
    Oct 21, 2011 at 23:16

1 Answer 1


Since the ITable must be created outside of a ComReleaser (and kept alive I presume while the in-memory join is active!) I discovered that the following code actually does release the 'named' table and thus allows me to use the same 'name' again so the renderer or annotations created when the original join was made continue to work with the updated join.

Marshal.FinalReleaseComObject( relQueryTable.DestinationTable );
Marshal.FinalReleaseComObject( relQueryTable );

As I read the help, DestinationTable is not required (but it didn't work correctly every time unless I included it!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.