4

Is there a way to programatically register a feature class as versioned?

I'm able to register aFeatureDatasetwith the IVersionObject3 interface, but not an individual feature class.

2

According to this example:

public void RegisterDataset(IDataset dataset)
{ 
    IVersionedObject3 versionedObject = (IVersionedObject3)dataset;

    bool IsRegistered;
    bool IsMovingEditsToBase;

    versionedObject.GetVersionRegistrationInfo(out IsRegistered, out IsMovingEditsToBase);

    if(IsRegistered)
    {
        if(IsMovingEditsToBase)
        {
            //first unregister without compressing edits
            versionedObject.UnRegisterAsVersioned3(false);

            //then register as fully versioned
            versionedObject.RegisterAsVersioned3(false);
        }
    }
    else
    {
        //registering as fully versioned
        versionedObject.RegisterAsVersioned3(false);
    }
}

IVersionedObject3 is implemented by IDataset. IDataset implements IFeatureClass and IFeatureDataset so it should work for either.

3
  • According to the documentation (resources.arcgis.com/en/help/arcobjects-net/componenthelp/…), IVersionedObject3 is implemented by NetworkDataset, CadastralFabric, StreetNetwork and Utility network... So, In theory, there is no way I can cast a FeatureClass insite a IVersionedObject3. In the same way, looking at the FeatureClass coclass documentation(resources.arcgis.com/en/help/arcobjects-net/componenthelp/…), there is no sign of IVersionEdit implementation.
    – Goldorak84
    Jul 31 '14 at 11:57
  • Even if it's not documented, I tested you solution and it works! Esri should update it's documentation though.
    – Goldorak84
    Jul 31 '14 at 12:03
  • 1
    Yes I think so. The listed interfaces do not include IDataset and as it implements that I think that's important. I think Esri has a "suggestions box"; it would be worth logging this as a deficiency. Jul 31 '14 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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