How to: Attach Reference Strings to Model Elements

In Visual Studio Ultimate, you can write code to attach arbitrary strings to model elements. A string could be, for example, a URI, the cached result of a computation, or a ModelBus reference to an element in another model. Each string is contained in an IReference object. Any number of IReference objects can be attached to each model element.

Every IReference object has a Name. You could use this Name to indicate how the reference value should be interpreted. For example, you could set Name to "URI" to indicate that the Value should be interpreted as a URI. There are some predefined reference name values used by the modeling tools.

To use the following methods, you must add a reference to:


You should insert this directive in your code:

using Microsoft.VisualStudio.ArchitectureTools.Extensibility.Uml;

Method call


element.AddReference (nameString, valueString, duplicatesAllowed)

Creates an IReference with the given name and value strings, and links it to element. Returns the IReference.

Throws an exception if duplicatesAllowed is false and there is already an IReference with the same name attached to element.


Returns all the IReference objects linked to element that have the given name.


Deletes all the IReference objects linked to element that have the given name.


Deletes this IReference.


The value used to name work item references.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft