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