Hi Jeremy,
Thanks for your help.
My document have one linked project in it, but it tried to run the code in a document with no links and I keep getting the same error. This is the code that I've been using for testing.
public void CreateESDSchema()
{
using (Transaction trans = new Transaction(_doc, "Create Schema"))
{
trans.Start();
Schema schema = Schema.Lookup(_schemaGuid);
if (schema == null)
{
SchemaBuilder schemaBuilder = new SchemaBuilder(_schemaGuid);
schemaBuilder.SetSchemaName("Tracking Elements");
schemaBuilder.SetReadAccessLevel(AccessLevel.Public);
schemaBuilder.SetWriteAccessLevel(AccessLevel.Public);
FieldBuilder fieldBuilder = schemaBuilder
.AddSimpleField("LinkedInstanceElementID", typeof(int));
fieldBuilder.SetDocumentation("Instance Element Unique ID");
fieldBuilder = schemaBuilder
.AddSimpleField("LinkedTypeElementID", typeof(int));
fieldBuilder.SetDocumentation("Type Element Unique ID");
fieldBuilder = schemaBuilder
.AddArrayField("InstanceParameters", typeof(string));
fieldBuilder.SetDocumentation("List of instance parameters");
fieldBuilder = schemaBuilder
.AddArrayField("TypeParameters", typeof(string));
fieldBuilder.SetDocumentation("List of type parameters");
fieldBuilder = schemaBuilder
.AddSimpleField("LinkedDocument", typeof(string));
fieldBuilder.SetDocumentation("Document where element is linked");
schema = schemaBuilder.Finish(); // register the Schema object
}
trans.Commit();
}
}
public void SetDataLinkedInsElemID(int id)
{
using (Transaction trans = new Transaction(_doc, "Store Data trans"))
{
trans.Start();
Schema schema = Schema.Lookup(_schemaGuid);
Entity entity = new Entity(schema);
entity.Set<int>(schema.GetField("ESD_LinkedInstanceElementID"), id);
_modelElementInstance.SetEntity(entity);
trans.Commit();
}
}
public void DeleteSchema()
{
Schema schema = Schema.Lookup(_schemaGuid);
Schema.EraseSchemaAndAllEntities(schema, true);
}
The variable _modelElementInstance it's an element that I manually pick.
If I run this when deleting the Schema I get the InternalException.
CreateESDSchema();
SetDataLinkedInsElemID(123456);
DeleteSchema();
In one of your articles (http://thebuildingcoder.typepad.com/blog/2013/08/deleting-and-updating-extensible-storage-schema.htm...) someone have a similar issue. Can you confirm if the issue is caused because the linked files?
Regarding my code for testing, am I doing something wrong?
I highgly apreciate your help.
Thanks again,
Marc