Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Does this thread help at all?… – blah238 Oct 21 '11 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 '11 at 23:16
up vote 2 down vote accepted

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!)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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