.NET error when selecting elements with manually attached EC data in the Item Browser


 Product(s):AECOsim Building Designer
 Version(s):08.11.09.866
 Environment:N\A
 Area:Platform Tools
 Subarea:DevTools - API

Error or Warning Message

Cannot display the specified content in the grid.
User Supplied Message: Cannot display the specified content in the grid.
A NullReferenceException was thrown: System.NullReferenceException: Object reference not set to an instance of an object.

Explanation

I have manually attached EC schema data to elements in my 3D Model using the steps described here: http://communities.bentley.com/products/programming/microstation_programming/f/19569/p/76005/205473#205473  

After, when using the Item Browser within AECOSim Building Designer SELECTserie6 (or Microstation) and clicking on these elements in the tree, I get the errors mentioned above.

How to Avoid

There is invalid metadata included in the schema that is causing this error, specifically, ‘IECArrayType containerProperty = m_instance.ClassDefinition[m_adhocSpec.AdhocPropertyContainer].Type as IECArrayType’, where ‘m_adhocSpec.AdhocPropertyContainer’ is “P02”, and there is no “P02” property in the schema or its base classes.  Since there are no properties which are of the correct type to be used as an adhoc value container, you should add a property of the correct type if you would like to use adhocs in this manner.

Note: In CONNECT Edition products the underlying process is a bit different in that it allows more than one adhoc property container per class so doesn’t rely on ‘AdhocPropertySpecification’ to identify adhoc container property definitions.  Additionally the code which takes the input container property name and constructs the AdhocPropertyContainerDefinition properly checks that the container property name is valid.  The end result is that under the same scenario as outlined above in V8i, the Item Browser in CONNECT Edition will not throw any errors and the Properties dialog will display.

 

 Original Author:Steve Cocchi