Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Marco Zapletal on August 31, 2005, 01:43:16 pm

Title: debuging  an add-in from vs.net
Post by: Marco Zapletal on August 31, 2005, 01:43:16 pm
folks,

can somebody give me a hint, how to attach a debugger from vs.net to an EA addin?
till now, i wrote testclasses for my code and started them from vs.net in debug mode. but sometimes it would be helpful to debug the addin directly in EA.

i hope i put my question clearly ;-)

thanks,
marco
Title: Re: debuging  an add-in from vs.net
Post by: TomO on August 31, 2005, 07:24:50 pm
Hey Marco,

I have just developed an Add-In here:  
C# How to create a Basic Add-In
http://sparxsystems.com.au/resources/developers/autint.html

It has documentation on how to setup VS2003 so you can run your Add-In and EA at the same time while debugging. I hope it helps!

Best Regards
TomO
Title: Re: debugging  an add-in from vs.net
Post by: Paolo F Cantoni on August 31, 2005, 07:52:23 pm
Hi Tom,

that Add-In stuff looks good!

However, I have an Add-On, not an Add-In (that is a Windows Application that references the EA AI).  I haven't been able to debug EA objects.  I looked through what you wrote in the ReadMe in case there was something there that I had missed (I'm new to C# and .Net).  

I found Register for COM Interop set to False in the Windows app (greyed out) and also set to False, but changeable in the main Component that does most of the work of accessing the AI.  So I set that to True.

However, no change?   :(

When I try to "watch" the attribute such as eaPackage.Name, I get the error: "eaPackage.Name" does not exist.  (However, I obviously can use it and assign it.)

Any advice for my situation?

Cheerz,
Paolo
Title: Re: debugging  an add-in from vs.net
Post by: TomO on August 31, 2005, 09:13:54 pm
Quote
When I try to "watch" the attribute such as eaPackage.Name, I get the error: "eaPackage.Name" does not exist.  (However, I obviously can use it and assign it.)


Hey Paolo,
Actually there is a way to "watch" that attribute. You will notice in the watch area if you just add eaPackage you will get a value of {EA.PackageClass} and a type of EA.Package. Because of the nature of this relationship you can't just ask VS to watch eaPackage.Name as Name is not a member of Package, its a member of PackageClass.

To view the eaPackage.Name attribute expand your "watched" eaPackage, open the EA.PackageClass find the name attribute and "drag it out of PackageClass" you will now find a new watch element called ((EA.PackageClass)(eaPackage)).Name with the value you are after.  

In short using the C# notation, you are casting eaPackage (of type EA.Package) to type EA.PackageClass so you can then access the attribute.

I hope this helps Paolo
Best Regards
TomO
Title: Re: debuging  an add-in from vs.net
Post by: Marco Zapletal on August 31, 2005, 11:43:30 pm
its working...thanks a lot for your hints tom.
Title: Re: debugging  an add-in from vs.net
Post by: Paolo F Cantoni on September 01, 2005, 12:22:45 am
Quote

Hey Paolo,
Actually there is a way to "watch" that attribute. [size=13][SNIP][/size]

In short using the C# notation, you are casting eaPackage (of type EA.Package) to type EA.PackageClass so you can then access the attribute.

I hope this helps Paolo
Best Regards
TomO
Hi Tom,
I understand what you are trying to do with the cast, but when I put in:
((EA.PackageClass)(eaPackage)).Name
I get:

((EA.PackageClass)(eaPackage)).Name
   <error: an exception of type: {System.ArgumentException} occurred>    
string

???
Paolo

Title: Re: debugging  an add-in from vs.net
Post by: Marco Zapletal on September 01, 2005, 01:28:28 am
Quote

Hey Paolo,
Actually there is a way to "watch" that attribute. You will notice in the watch area if you just add eaPackage you will get a value of {EA.PackageClass} and a type of EA.Package.


sometimes if have this type/value construct you describe, but often my objects have {System.__ComObject} as value. may someone has an explanation for me? ;)
Title: Re: debugging  an add-in from vs.net
Post by: TomO on September 01, 2005, 05:21:59 pm
Quote
I understand what you are trying to do with the cast, but when I put in:
((EA.PackageClass)(eaPackage)).Name
I get:

((EA.PackageClass)(eaPackage)).Name
    <error: an exception of type: {System.ArgumentException} occurred>    


I think the easiest way to do it, although it's a little slower, is to place the parent object in first, in this case just a watch on eaPackage. From there you can drill down to the actual attribute you wish to view, and drag it out on its own, vs.net will do all the conversion for you.

TomO
Title: Re: debugging  an add-in from vs.net
Post by: Paolo F Cantoni on September 06, 2005, 09:13:16 pm
Quote

I think the easiest way to do it, although it's a little slower, is to place the parent object in first, in this case just a watch on eaPackage. From there you can drill down to the actual attribute you wish to view, and drag it out on its own, vs.net will do all the conversion for you.

TomO
Hi Tom,

I've been trying your suggestion and only once in 3 days did it work. :(  Unfortunately, when it did I was so shocked :o, I didn't note the circumstances.

Any other ideas?

TIA,
Paolo