IField.Domain is NULL after adding a new field with domain using IFieldEdit2

Discussion created by mmatsuoka on Nov 10, 2011
Latest reply on Nov 10, 2011 by mmatsuoka
I created an ArcCatalog AddIn. After running the code below to a feature class in a file geodatabase, if I do (<table>.Fields.get_Field(<index of the new field>)).Domain, it says the domain property is NULL. If I look at the property of the new field the ArcCatalog, it initially says the domain is not assigned, but once I restart ArcCatalog, it says the domain is assigned to the field. Can someone tell me what I am missing? Thanks.

ISchemaLock schemaLock = (ISchemaLock)tbl;
                /// Create the new field
                IField newField = new FieldClass();
                IFieldEdit2 fieldEdit = (IFieldEdit2)newField;
                fieldEdit.AliasName_2 = aliasName;
                fieldEdit.DefaultValue_2 = defaultValue;
                fieldEdit.Domain_2 = domain;
                fieldEdit.DomainFixed_2 = domainFixed;
                fieldEdit.IsNullable_2 = isNullable;
                fieldEdit.Length_2 = length;
                fieldEdit.Name_2 = name;
                fieldEdit.Precision_2 = precision;
                fieldEdit.Required_2 = required;
                fieldEdit.Scale_2 = scale;
                fieldEdit.Type_2 = type;
                /// Add the field.