Monday, April 16, 2012

Error:Object reference not set to an instance of an object enterprise architect and visual studio

i get this error when i try to compile my program using Visual Studio and Enterprise Architect.

I'm writing a tool for Enterprise Architect, and i have to make a graph, and i continue to get this error, i don't know what to do.

The code that i have problem with is:

    public Graph(EA.Repository repository)

EA.Diagram maindiagram;
this.modelRepository = repository;
maindiagram = repository.GetCurrentDiagram(); //recupero del diagramma
this.diagramId = maindiagram.DiagramID; //identificativo del diagramma

//inizializzazione nodi
Collection nodeCollection = maindiagram.DiagramObjects;
nodeList = new ArrayList();

foreach (DiagramObject diagram in maindiagram.DiagramObjects)
foreach (Element element in diagramList)
if (element.Type == "Class"|| element.Type == "Component"||element.Type == "Package")
{ nodeList.Add(new Node(diagram, ref repository)); }



//inizializzazione archi
Collection linkCollection = maindiagram.DiagramLinks;
linkList = new ArrayList();

foreach (DiagramLink edge in maindiagram.DiagramLinks)
foreach(Connector connector in edgeList)
if (connector.Type == "Association" || connector.Type == "Aggregation" || connector.Type == "Compose" || connector.Type == "Dependency"
|| connector.Type == "Generalization" || connector.Type == "Realization")
{ linkList.Add(new Link (edge, ref repository));}

Please help if you know how.

Thank you a lot!

No comments:

Post a Comment