Visual StudioとEnterprise Architectを使用してプログラムをコンパイルしようとするとこのエラーが発生します。エラー:オブジェクト参照がオブジェクトエンタープライズアーキテクトとビジュアルスタジオのインスタンスに設定されていません
私はEnterprise Architect用のツールを書いています。グラフを作成する必要があります。このエラーが引き続き発生するため、何をすべきか分かりません。私は問題を抱えている
コードは次のとおりです。あなたはどのように知っていれば
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)
{
diagramList.Add(diagram);
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)
{
edgeList.Add(edge);
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));}
}
助けてください。
ありがとうございました!
エラーの表示先は? –
問題はmaindiagramの割り当てにあり、結果としてnullと表示されます。そして、私はそれがどのようにnullになることができるか分からない。もう一つは、メインダイアグラムの最初のforeachにあります。私は同じ理由で仮定します。私はmaindiagramの問題を解決する必要がありますが、私はどのようにGetCurrentDiagram()は、あなたがエンタープライズアーキテクトで開いているダイアグラムを取得する必要がありますかわからない。 – Defi