Book a Demo

Author Topic: Addin EA.Repository in C#  problem with extension  (Read 4155 times)

MathiasK

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Addin EA.Repository in C#  problem with extension
« on: April 24, 2014, 05:49:39 pm »
Hi iam exploring the EA Model with api and c# and have a question:

I tryed in two ways to print the modelname , both appear similar to me but the one wich i would prefer shows a error message about error at the "name" of the Model:


EA.Repository r = new EA.Repository();
 r.OpenFile("//krill/Enterprise Architect/EA Models/Models/sampleModel.eap");

 //AbsolutePath of the Repository - works
 form.richTextBox1.AppendText("Repository : " + (r.ConnectionString) + Environment.NewLine);

 
 //Works but displayed as error in Visual Studio at "name"
 EA.Collection root = r.Models.GetAt(0);
form.richTextBox1.AppendText("root : " + root.name + Environment.NewLine);

 
//Works , no displayed error
 EA.Collection root2 = r.Models;

 form.richTextBox1.AppendText("root : " + root2.GetAt(0).name + Environment.NewLine);


Error msg is:
"Error      1             'EA.Collection' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'EA.Collection' could be found (are you missing a using directive or an assembly reference?)                C:\VisualStudioCSharp\EAWindowsFormApp01\EAWindowsFormApp01\Program.cs  35           59                EAWindowsFormApp01"


Ideas ^^ ?
The Interop.EA is referenced.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Addin EA.Repository in C#  problem with extens
« Reply #1 on: April 24, 2014, 05:56:04 pm »
Quote
Hi iam exploring the EA Model with api and c# and have a question:

I tryed in two ways to print the modelname , both appear similar to me but the one wich i would prefer shows a error message about error at the "name" of the Model:


EA.Repository r = new EA.Repository();
 r.OpenFile("//krill/Enterprise Architect/EA Models/Models/sampleModel.eap");

 //AbsolutePath of the Repository - works
 form.richTextBox1.AppendText("Repository : " + (r.ConnectionString) + Environment.NewLine);

 
 //Works but displayed as error in Visual Studio at "name"
[highlight] EA.Collection root[/highlight] = r.Models.GetAt(0);
form.richTextBox1.AppendText("root : " + root.name + Environment.NewLine);

 
//Works , no displayed error
 EA.Collection root2 = r.Models;

 form.richTextBox1.AppendText("root : " + root2.GetAt(0).name + Environment.NewLine);


Error msg is:
"Error      1             'EA.Collection' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'EA.Collection' could be found (are you missing a using directive or an assembly reference?)                C:\VisualStudioCSharp\EAWindowsFormApp01\EAWindowsFormApp01\Program.cs  35           59                EAWindowsFormApp01"


Ideas ^^ ?
The Interop.EA is referenced.
If you type your variable root as an EA.Collection then you don't have a name property as the error indicates.

Geert
« Last Edit: April 24, 2014, 05:57:13 pm by Geert.Bellekens »

MathiasK

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Addin EA.Repository in C#  problem with extens
« Reply #2 on: April 24, 2014, 07:22:11 pm »
 :-[
yes... thx  :)