AnsweredAssumed Answered

Cannot Delete Version

Question asked by bbehling on May 31, 2013
Latest reply on May 31, 2013 by bbehling
When I try to delete a version, even after stopping the edit operations, ArcObjects is telling the version is in use and it wont delete it.

I tried setting all objects that are referenced by the version object to and calling the garbage collector like in this post

but that doest work. Also tried setting the version access to public, still no go. Even tried tried creating another object derviced from a versionedWorkspace, still nothing.

Also checked for locks, and there are no locks on this version.

Any one else have success deleting a dynamically created version? Wondering if this is a bug.

Random random = new Random();
string versionNum = random.Next(0, 1000000000).ToString();

IVersion targetVersion = (IVersion)sdeWorkspace;
IVersion newVersion = targetVersion.CreateVersion(versionNum);

//IMultiuserWorkspaceEdit muWorkspaceEdit = (IMultiuserWorkspaceEdit)newVersion;

IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)newVersion;
IVersionEdit4 versionEdit = (IVersionEdit4)workspaceEdit;

//Do some edits

versionEdit.Reconcile4(targetVersion.VersionName, true, false, false, false);


targetVersion = null;
workspaceEdit = null;
versionEdit = null;

IEnumLockInfo test = newVersion.VersionLocks;
ILockInfo test2 = null;

while((test2 = test.Next()) != null)
    //no locks present

newVersion.Delete(); //ArcObjects says version is in use