Book a Demo

Author Topic: Cannot update connector  (Read 7324 times)

msdb

  • EA Novice
  • *
  • Posts: 10
  • Karma: +1/-0
    • View Profile
Cannot update connector
« on: June 01, 2016, 06:30:34 pm »
In my C# program i have a method that should create a connector between two elements but it's throwing this error:
Quote
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in SparxProject.exe

Additional information: Cannot update connector as either the Start or the End object is NULL

The method:
Code: [Select]
static void LinkToSuperDepartment(Element subDepartmentOrEmployee, int superDepartment)
        {
            Connector aggregationConnector = subDepartmentOrEmployee.Connectors.AddNew("", "Connector");
            aggregationConnector.Type = "Aggregation";
            aggregationConnector.Stereotype = "Archimate2::ArchiMate_Aggregation";
            aggregationConnector.ClientID = subDepartmentOrEmployee.ElementID;
            aggregationConnector.SupplierID = superDepartment;
            aggregationConnector.Direction = "Source -> Destination";
            aggregationConnector.Update();

        }

The error occurs when Update() is called.

Do ClientID and SupplierID not specify the start and end objects of the connector?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Cannot update connector
« Reply #1 on: June 01, 2016, 06:38:34 pm »
You don't have to set the clientID, that is set automatically because you add it to SubDepartmentOrEmployee.
But you have to make sure that superDepartment actually points to an existing element (that is already been saved)

Geert

msdb

  • EA Novice
  • *
  • Posts: 10
  • Karma: +1/-0
    • View Profile
Re: Cannot update connector
« Reply #2 on: June 02, 2016, 06:24:22 pm »
Okay, I see my mistake now. Thank you.