FindVersion finds deleted versions

Discussion created by BillyBuerger on Jan 4, 2013
Latest reply on Jan 6, 2013 by BillyBuerger
I have a custom version management tool that I use and it creates/deletes/etc versions on a SDE geodatabase.  One thing I just noticed is that I can create a version using DefaultVersion.Create("test1"), delete the version using Test1Version.Delete(), then call VersionedWorkspace.FindVersion("test1") and get an IVersion back instead of throwing an exception like it does normally when a version doesn't exist.  Any attempt to do anything with this IVersion fails as the version has been deleted.  It would seem that maybe I'm missing something in the IVersion.Delete() method as this only happens after I delete a version.  If I create the version, then use the built in Arc tools to delete the version, I can create a new version with no problems.  But if I get it to this situation where it finds the deleted version, then the Arc tools for deleting a version also give me an error.  I have to close out of ArcCatalog and re-open before it works again.  Is there some event or something that tells the workspace that the version has been deleted that isn't happening?  Could it be that there's some reference to the version that isn't being released and causing the COM object to stay around?

Here's some sample code that shows the issue...

IVersionedWorkspace work = //<an SDE geodatabase>;
IVersion DefaultVersion = work.DefaultVersion;
IVersion Test1Version = DefaultVersion.CreateVersion("test1");
IVersion Test2Version = work.FindVersion("test1");
//No exception but Test2Version.VersionName = 'Test2Version.VersionName' threw an exception of type 'System.Runtime.InteropServices.COMException';