I need to delete a domain in my database. Since the domain is still associated with a field, I first need to delete the association. After reading the documentation for IWorkspaceDomains.DeleteDomain, it say to use the IClassSchemaEdit.AlterDomain.
So I try using this code to remove the association
Dim workspaceDomains As IWorkspaceDomains = CType(workspace, IWorkspaceDomains) Dim feature As IFeatureClass Dim schemaLock As ISchemaLock = Nothing Dim classSchemaEdit As IClassSchemaEdit feature = CType(workspace, IFeatureWorkspace).OpenFeatureClass("FeatureClassName") Try schemaLock = CType(feature, ISchemaLock) schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock) classSchemaEdit = CType(feature, IClassSchemaEdit) classSchemaEdit.AlterDomain("FieldName", Nothing) Finally If (Not schemaLock Is Nothing) Then schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock) End If End Try
When it comes to executing this line
classSchemaEdit.AlterDomain("FieldName", Nothing), I get this error :
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in DLLFile.dll
Additional information: Error HRESULT E_FAIL has been returned from a call to a COM component.
So I when back and check the documentation for IClassSchemaEdit.AlterDomain to see how to remove the association, but I found nothing.
What is it that I'm doing wrong. I know I could just copy the data to a new field and delete the original, but this mean that I would have to modify a toolbox, but I would rather avoid it.