Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - arunraj

Pages: [1]
1
I have a console application written in C# that uses the Interop.EA.dll (from EA v12.1 on Windows 10 64bit) to create an EAP model. My app attempts to create a large number of packages, elements and diagrams.

The EA.Package, EA.Element and EA.Diagram objects are successfully created. However when I try to create EA.Element objects of type 'InteractionFragment' and EA.Partition objects, the app randomly receives the following exception:

Code: [Select]
System.Runtime.InteropServices.COMException: 'The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)'
The EA process which runs in parallel terminates and hence I am unable to debug any of the COM objects (watch window shows '((EA.DiagramClass)eaDiagram).DiagramObjects' threw an exception of type 'System.Runtime.InteropServices.COMException').
I tried to debug my app for null pointers, memory leaks etc. and everything seems to be in order. As a matter of fact, my app runs without any errors using a different configuration but the generated model was small.

Suspecting a memory fragmentation issue, I tried to close and reopen EA instance within my app. It did not help. I also tried calling Marshal.ReleaseComObject() but continued receiving the exception randomly. The location at which I receive the COM exception is different for each run.

As EA does not log errors (something that EA should definitely do!) and I was running out of options, I attached the debugger to the running EA process spawned by the Interop.EA.dll and observed that I receive the following exception:

Code: [Select]
Exception thrown at 0x00D5AA3E in EA.exe: 0xC0000005: Access violation writing location 0x28070B24.
Callstack:
Code: [Select]
> EA.exe!00d5aa3e() Unknown
  [Frames below may be incorrect and/or missing, no symbols loaded for EA.exe] Unknown
  EA.exe!005d5e3e() Unknown
  EA.exe!017bfc35() Unknown
  EA.exe!008ca7b0() Unknown
  EA.exe!008cafa6() Unknown
  EA.exe!017b4581() Unknown
  EA.exe!017bfc35() Unknown
  combase.dll!76b22e4b() Unknown
  combase.dll!76a73ab0() Unknown
  combase.dll!76ac44ae() Unknown
  combase.dll!76ac7c1d() Unknown
  combase.dll!76acb252() Unknown
  combase.dll!76aeaf4b() Unknown
  combase.dll!76ace495() Unknown
  rpcrt4.dll!76cc23fc() Unknown
  rpcrt4.dll!76c84f7c() Unknown
  oleaut32.dll!75227ce0() Unknown
  combase.dll!76a89321() Unknown
  combase.dll!76a89123() Unknown
  combase.dll!76a88c87() Unknown
  combase.dll!76abd951() Unknown
  user32.dll!76dc61bb() Unknown
  EA.exe!017aec45() Unknown
  EA.exe!00f8b5f1() Unknown
  EA.exe!017b1c72() Unknown
  user32.dll!76dc61bb() Unknown
  user32.dll!76db74dc() Unknown
  EA.exe!017aeae1() Unknown
  EA.exe!00b169e7() Unknown
  EA.exe!017bc2ca() Unknown
  EA.exe!01829025() Unknown
  EA.exe!017fd94e() Unknown
  kernel32.dll!74ea0419() Unknown
  ntdll.dll!7701662d() Unknown
  ntdll.dll!770165fd() Unknown

As I did not have much to debug further, I clicked 'Continue' and then the second exception occurs:

Code: [Select]
Unhandled exception at 0x77040711 (ntdll.dll) in EA.exe: 0xC015000F: The activation context being deactivated is not the most recently activated one (parameters: 0x00000003, 0x03A8FDA4, 0x03BC4258).
Callstack:
Code: [Select]
> ntdll.dll!77040711() Unknown
  [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] Unknown
  ntdll.dll!77040711() Unknown
  user32.dll!76dc61bb() Unknown
  user32.dll!76db74dc() Unknown
  user32.dll!76db661b() Unknown
  user32.dll!76db63f0() Unknown
  EA.exe!017bc652() Unknown
  EA.exe!017bc2ca() Unknown
  EA.exe!01829025() Unknown
  EA.exe!017fd94e() Unknown
  kernel32.dll!74ea0419() Unknown
  ntdll.dll!7701662d() Unknown
  ntdll.dll!770165fd() Unknown

I again clicked 'Continue' and after around 28 such exceptions, my app finishes without receiving the RPC exception! Can someone please explain this strange behavior?

2
I am not a fan of Windoof either - just stuck with it. :D

Anyway since you said that you have a Perl environment, I wrote a Perl script for my desired scenario. Please see the full script here:

Code: [Select]
#!/usr/bin/perl

use Win32::OLE;

$repo = Win32::OLE->new('EA.Repository', \&OleQuit) or die "Unable to use COM interface";

$repo->OpenFile("C:\\Test\\Test.EAP") or die "File not found";

$models = $repo->{Models};

$myModel = $models->AddNew("Test", "");
$myModel->Update() or die "Error";

$rootPackages = $myModel->{Packages};

$rootPackage = $rootPackages->AddNew("Root", "");
$rootPackage->Update() or die "Error";

$rootPackageDiagrams = $rootPackage->{Diagrams};

$rootPackageDiagram = $rootPackageDiagrams->AddNew("RootDiagram", "CompositeStructure");
$rootPackageDiagram->Update() or die "Error";

$rootPackageElements = $rootPackage->{Elements};

$topPartElement = $rootPackageElements->AddNew("TopPart", "Part");
# Setting IsComposite here has weird results - setting it after creating the diagram gives expected result!
# $topPartElement->IsComposite = true;
$topPartElement->Update() or die "Error";

$rootPackageDiagramObjects = $rootPackageDiagram->{DiagramObjects};

$rootPackageDiagramObject = $rootPackageDiagramObjects->AddNew("", "");
$rootPackageDiagramObject->{ElementID} = $topPartElement->ElementID;
$rootPackageDiagramObject->Update() or die "Error";

$topPartDiagrams = $topPartElement->{Diagrams};

$topPartDiagram = $topPartDiagrams->AddNew("TopPartDiagram", "CompositeStructure");
$topPartDiagram->Update() or die "Error";

$topPartElement->{IsComposite} = true;
$topPartElement->Update() or die "Error";

$topPartEmbeddedElements = $topPartElement->{EmbeddedElements};

$subPartElement = $topPartEmbeddedElements->AddNew("SubPart", "Part");
$subPartElement->Update() or die "Error";

$topPartDiagramObjects = $topPartDiagram->{DiagramObjects};

$subPartDiagramObject = $topPartDiagramObjects->AddNew("", "");
$subPartDiagramObject->{ElementID} = $subPartElement->ElementID;
$subPartDiagramObject->Update() or die "Error";

$subPartEmbeddedElements = $subPartElement->{EmbeddedElements};

$portElement = $subPartEmbeddedElements->AddNew("Port", "Port");
$portElement->Update() or die "Error";

#$portDiagramObject = $topPartDiagramObjects->AddNew("", "");
#$portDiagramObject->{ElementID} = $portElement->ElementID;
#$portDiagramObject->Update() or die "Error";

$repo->CloseFile();
$repo->Exit();

sub OleQuit {
   my $self = shift;
   $self->Exit();
}


The above code works. Next I un-comment and enable the following code section:

Code: [Select]
$portDiagramObject = $topPartDiagramObjects->AddNew("", "");
$portDiagramObject->{ElementID} = $portElement->ElementID;
$portDiagramObject->Update() or die "Error";

This gives: Error at sample.pl line 63. (the exact problem I am having in my JAVA program and C# test program)

3
Alright. My original program was in JAVA and when I faced the issue, I did not have any valid error messages from the EA JAR library. Hence I decided to replicate the same scenario using C# hoping that the DLL would give me a meaningful error but without success.

I did a bit of experimentation and found that the problem happens exactly with that hierarchy and where I want the DiagramObjects to be added in the diagram. That is why I mentioned it in my first post. What I found was, if I add an intermediate Part element, the code would work! Something like this:

Code: [Select]
Root (Package)
|
|--RootDiagram (Diagram:CompositeStructure)
|
|--TopPart (Element:Part, IsComposite=true)
    |
    |--TopPartDiagram (Diagram:CompositeStructure)
    |
    |--DummyPart  (Element:Part)
        |
        |--SubPart (Element:Part)
            |
            |-Port (Element:Port)

Notice the DummyPart is now the parent and the outermost Part in the diagram. With this, I am able to add the Port to the SubPart via code - it looked to me like a problem with the hierarchy that I want but I do not understand why.

Would it be possible for you to try my exact code? I did not yet attempt to try it via Perl script.

4
That's strange. I tried first with v13 and also with v12. Same results unfortunately.  :(

This what I see from my console:
Code: [Select]
Unhandled Exception: System.Runtime.InteropServices.COMException: The remote procedure call failed. (Exception from HRESULT: 0x800706BE)
   at EA.IDualDiagramObject.Update()
   at Test.Test.Main(String[] args) in C:\Test\Test.cs:line 128
Press any key to continue . . .

When I comment out the creation of oPortDiagramObject, setting the element ID and updating the object, the program works without any troubles. You do not see any such errors or crashes with the same code and can see the Port added to SubPart under the TopPartDiagram?

5
I did not describe the entire steps because I thought those were obvious. Anyway for better clarity, here is the complete code:

Code: [Select]
EA.Repository oRepository = new EA.Repository();

oRepository.OpenFile("C:\\test.eap");

EA.Package oModel = (EA.Package)oRepository.Models.AddNew("Test", "");
if(!oModel.Update()) { Console.WriteLine("Error"); }

EA.Package oRootPackage = (EA.Package)oModel.Packages.AddNew("Root", "");
if(!oRootPackage.Update()) { Console.WriteLine("Error"); }

EA.Diagram oRootDiagram = (EA.Diagram)oRootPackage.Diagrams.AddNew("RootDiagram", "CompositeStructure");
if(!oRootDiagram.Update()) { Console.WriteLine("Error"); }

EA.Element oPartElement = (EA.Element)oRootPackage.Elements.AddNew("TopPart", "Part");
// Setting IsComposite here has weird results - setting it after creating the diagram gives expected result!
// oPartElement.IsComposite = true;
if(!oPartElement.Update()) { Console.WriteLine("Error"); }

EA.DiagramObject oPartDiagramObject = (EA.DiagramObject)oRootDiagram.DiagramObjects.AddNew("", "");
oPartDiagramObject.ElementID = oPartElement.ElementID;
if(!oPartDiagramObject.Update()) { Console.WriteLine("Error"); }

EA.Diagram oPartDiagram = (EA.Diagram)oPartElement.Diagrams.AddNew("TopPartDiagram", "CompositeStructure");
if(!oPartDiagram.Update()) { Console.WriteLine("Error"); }

oPartElement.IsComposite = true;
if(!oPartElement.Update()) { Console.WriteLine("Error"); }

EA.Element oSubPartElement = (EA.Element)oPartElement.EmbeddedElements.AddNew("SubPart", "Part");
if(!oSubPartElement.Update()) { Console.WriteLine("Error"); }

EA.DiagramObject oSubPartDiagramObject = (EA.DiagramObject)oPartDiagram.DiagramObjects.AddNew("", "");
oSubPartDiagramObject.ElementID = oSubPartElement.ElementID;
if(!oSubPartDiagramObject.Update()) { Console.WriteLine("Error"); }

EA.Element oPortElement = (EA.Element)oSubPartElement.EmbeddedElements.AddNew("Port", "Port");
if(!oPortElement.Update()) { Console.WriteLine("Error"); }

EA.DiagramObject oPortDiagramObject = (EA.DiagramObject)oPartDiagram.DiagramObjects.AddNew("", "");
oPortDiagramObject.ElementID = oPortElement.ElementID;
if(!oPortDiagramObject.Update()) { Console.WriteLine("Error"); }

oRepository.CloseFile();
oRepository.Exit();
oRepository = null;

The oPortDiagramObject.Update() is what fails. Am I doing something wrong here?

6
I am using the EA COM API via C# and trying to create the following hierarchy model:
Code: [Select]
Root (Package)
|
|--RootDiagram (Diagram:CompositeStructure)
|
|--TopPart (Element:Part, IsComposite=true)
    |
    |--TopPartDiagram (Diagram:CompositeStructure)
    |
    |--SubPart (Element:Part)
        |
        |-Port (Element:Port)

I use the Diagram.DiagramObjects.AddNew interface to add:
  • TopPart to the RootDiagram
  • SubPart to the TopPartDiagram
  • Port to the TopPartDiagram
Unfortunately the DiagramObject.Update succeeds only for 1 and 2. When I try to add the Port element, the process crashes with exception.

Via the GUI, I can add it by right clicking the SubPart and selecting Structural Elements. Why can't the automation API do the same thing?

Pages: [1]