I am trying to use OnInstanceUpdated but it doesn't even hit my breakpoint? (It does update the Schema, and returns Success, but it just seems to remove the element instances.)

private DGN.SchemaUpdateStatus UpdateSchema()
FindInstancesScope scope = FindInstancesScope.CreateScope(ActiveDgnFile, new FindInstancesScopeOption(DgnECHostType.File, false));
IECSchema dgnSchema = DgnECManager.Manager.LocateSchemaInScope(scope, SchemaName, VersionMajor, VersionMinor, SchemaMatchType.Latest);
if (null != dgnSchema)
DGN.SchemaUpdateStatus updStatus = DGN.SchemaUpdateStatus.Success;
if (dgnSchema.VersionMajor < VersionMajor || dgnSchema.VersionMinor < VersionMinor)
UpdateSchemaOptions opts = new UpdateSchemaOptions((ushort)ECProviderId, false, true);
DgnECManager.Manager.OnInstanceUpdated += UpdateInstanceHandler;
updStatus = DgnECManager.Manager.UpdateSchema(MySchema, ActiveDgnFile, opts);
DgnECManager.Manager.OnInstanceUpdated -= UpdateInstanceHandler;
return updStatus;
catch { }
return DGN.SchemaUpdateStatus.SchemaNotFound;

public override void UpdateInstanceHandler(IDgnECInstance ecInstance)
string msg = "WTF Tom?";   // <- Breakpoint
//SetPropertyStringValue(ecInstance, VersionName, Version()); <- I want to do more than this, just trying to test right now...

Parents Reply
  • Hi,

    My GetProperties() function does check the instance version and if not latest, it reads the instance as from the older version then adds the new values and rewrites it....

    I am not sure I understand the whole process right. When you update the schema, you do not update EC data instances, attached to elements. They are disconnected records.

    But why does it actually remove the instance when I do the UpdateSchema?

    I do not now. The problem is that UpdateSchemaOption class is NET API specific, not existing in native API.

    I recommend to try what happens when you pass null, because in such scenario, default UpdateSchemaOption configuration is used (the option class is created with default values, with default provider id and the update option set to false).

    I still think that the best way is to follow native API approach: To update schema separately, and to iterate and update EC data instances explicitly using own code. Because only you know, how the update should be done right.

    Or is it just that it doesn't display in properties until I fix the instance??

    My understanding of the display process is that when EC data instance is displayed, EC schema is analyzed for the data format. When specific EC property does not exist in the instance, it does not cause any problem (it's just null data). But I am not sure what happens when EC instance property exist, but it's not defined in EC schema. Maybe it's processed as ad-hoc EC data.

    I am using ProStructures Connect, v. and SDK v.

    It sounds like incompatible combination. SDK must alwyas be equal to PowerPlatform version. So you should check ustation.dll version (or to use "version" key-in in the product) to check what engine (PowerPlatform / MicroStation) version was used to build the product, and to use equal SDK.

    In fact, for NET, no SDK is necessary, because assemblies are delivered with the products, but it's about available documentation. And for some tasks (like to build ribbon definition in rsc format), SDK tools are required.

    And the documentation seems to be very incomplete.

    Yes. But you use the very first SDK version, which is very very very old and basic.

    I think the best for EC programming is MicroStation CE SDK Update 15 or 16.0, where EC APIs docs were included (for some reasons, they are not availble in the current SDK Update 16.2).

    With regards,