Author Topic: Cannot create a connector for a Package  (Read 800 times)

Rick Meng

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Cannot create a connector for a Package
« on: March 24, 2009, 10:21:04 am »
I am trying to create "A Package Dependencies" Diagram using C#.

 EA.Package pack = m_eaResp.GetPackageByGuid(packageGUID);
 EA.Connector con = (EA.Connector)m_package.Connectors.AddNew("Test Import", "");
 con.SupplierID = pack.Element.ElementID;
 con.Update();

The Update() function raises a COMException:

A COMException was raised after the con.Update() was executed.
Exception detail:

 

      COMException was unhandled

 

      The server threw an exception.( Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

 

 

StackTrace:

 

      "   at EA.IDualConnector.Update()\r\n   at EADemo.Form1.ConnectorTest() in C:\\Program Files\\Sparx Systems\\EA\\Code Samples\\C#_Sample\\Form1.cs:line 274\r\n   at EADemo.Form1.btnDoIt_Click(Object sender, EventArgs e) in C:\\Program Files\\Sparx Systems\\EA\\Code Samples\\C#_Sample\\Form1.cs:line 200\r\n   at System.Windows.Forms.Control.OnClick(EventArgs e)\r\n   at System.Windows.Forms.Button.OnClick(EventArgs e)\r\n   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)\r\n   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n   at System.Windows.Forms.Control.WndProc(Message& m)\r\n   at System.Windows.Forms.ButtonBase.WndProc(Message& m)\r\n   at System.Windows.Forms.Button.WndProc(Message& m)\r\n   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n   at System.Windows.Forms.Application.Run(Form mainForm)\r\n   at EADemo.Form1.Main() in C:\\Program Files\\Sparx Systems\\EA\\Code Samples\\C#_Sample\\Form1.cs:line 151\r\n   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ThreadHelper.ThreadStart()"

 
Is this the correct way to create a connector for a package? Are there some other way to create it?

Thank you very much!
« Last Edit: March 24, 2009, 10:21:47 am by rickmeng »

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6481
  • Karma: +56/-6
    • View Profile
Re: Cannot create a connector for a Package
« Reply #1 on: March 24, 2009, 10:27:58 am »
At a glance, you haven't specified a valid connector type.
Simon

support@sparxsystems.com

Rick Meng

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Cannot create a connector for a Package
« Reply #2 on: March 24, 2009, 10:33:40 am »
I do not know which type should I use. I want to show that a package import another one.

Rick Meng

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Cannot create a connector for a Package
« Reply #3 on: March 24, 2009, 10:38:44 am »
I did more testing. I have tried to use the following connector type. None of them work.
1. Aggregation
2. Association
3. Collaboration
4. Generalization

The only acceptable type is : Dependency.

Do you mean the above COMException was raised because the package object does not accept any other connector type except "Dependency"

Any way, "Dependency" works.

Thank you very much!
« Last Edit: March 24, 2009, 10:39:46 am by rickmeng »

Rick Meng

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Cannot create a connector for a Package
« Reply #4 on: March 24, 2009, 10:54:48 am »
The final workable code:

 string packageGUID = de.Key.ToString();
                    EA.Package pack = m_eaResp.GetPackageByGuid(packageGUID);
                    EA.Connector con = (EA.Connector)m_eaResp.GetElementByID(m_package.Element.ElementID).Connectors.AddNew("", "Dependency");
                    con.Stereotype = "Import";
                    con.SupplierID = pack.Element.ElementID;
                    con.Update();