Dear All,
I'm tring to write an addin in c# to manage a UML customized metamodel with EA.
But i got a strange exception when I try to analize connectors:
It seems that i'm not allowed to get/add tagged values to this items.

this are few lines from my code:
foreach( EA.Connector conn in child_req.Connectors )
if (conn.Stereotype == AppConfig.EAP_MY_LINK_STEREOTYPE)
{
EA.TaggedValue link_status_tag = BaseControl.GetTaggedValue(conn.TaggedValues, AppConfig.TAGVAL_MYLINK_STATUS);
if (link_status_tag == null)
{
//exception starts HERE
BaseControl.AddTaggedValue(conn.TaggedValues, AppConfig.TAGVAL_MYLINK_STATUS, AppConfig.EAP_TAGGEDVALUE_TYPE, AppConfig.MYLINK_STATUS_PROPOSED);
link_status_tag = BaseControl.GetTaggedValue(conn.TaggedValues, AppConfig.TAGVAL_MYLINK_STATUS);
}
...
and this are two helping functions that i call in the above snippet:
public class BaseControl
{
public static bool AddTaggedValue(EA.Collection coll, String name, String type, String value)
{
EA.TaggedValue tag = GetTaggedValue(coll, name);
[highlight]
//exception raised HERE[/highlight]
if(tag==null)
tag = (EA.TaggedValue)coll.AddNew(name, type);
tag.Value = value;
if (!tag.Update())
{
AppConfig.last_error_msg = "Cant add TaggedValue [" + name + "],[" + type + "],[" + value + "]";
return false;
}
return true;
}
public static EA.TaggedValue GetTaggedValue(EA.Collection coll, String name )
{
EA.TaggedValue tag = null;
try
{
tag = (EA.TaggedValue) coll.GetByName(name);
}
catch (Exception)
{
return null;
}
return tag;
}
when I try to run this, i got this:
Impossibile eseguire il cast di oggetti COM di tipo 'System.__ComObject' in tipi di interfaccia 'EA.TaggedValue'. L'operazione non è stata completata perché la chiamata QueryInterface sul componente COM per l'interfaccia con IID '{EF08950B-949E-435F-84A3-A59E3106C3BF}' non è riuscita a causa del seguente errore: Interfaccia non supportata. (Eccezione da HRESULT: 0x80004002 (E_NOINTERFACE)).
that Translated in English says that it is not possible to cast the returned value [from Collection.AddNew()] in the EA.TaggedValue inteface. Operation not completed from the QueryInterface because the interface is not supported

.
I use the string type: "TaggedValue" when calling the Collection.AddNew() method.
( ie: AppConfig.EAP_TAGGEDVALUE_TYPE = "TaggedValue" )
Note that: my code tries to insert a new tagged value because it not finds the specified taggedValue... but it should exists in the model. (I've created manully in a diagram using a drag&drop mode).
Why this happens? could someone helpme please?
Thankyou

/D