Hi,
I'm creating an add-in for EA and I found a weird symptom.
I have foreach loop with recursive method inside. This code made the EA crash, each time it is executed (Error Report from Microsoft will pop up, letting me choose whether want to send the error). This case only happen if I make a build in
Release mode and install it to my computer (and other computer too).
BUT, if I create the build with
Debug mode. The code runs successfully.
After I change "foreach" loop into "for" loop, the release version build works fine.
I was thinking that it might be an .Net's bug on looping through collection. But I have tested recursive method inside "foreach" with another collection other than EA collection (i.e. Directory.GetDirectories()), it runs successfully.
So I begin to think that it might be an EA collection's bug. I'm not sure about this, but I think it's good to let the other know to avoid the same problem, coz it is really hard to find where the error is and tooks me 2 weeks to solve the problem.
Here is the link who has the same problem as me.
http://social.msdn.microsoft.com/Forums/en-US/clr/thread/9a4e8bbb-efbd-4a90-9549-4e1795198800/Here is my code before :
private void iterate(EA.Element element, XmlSchema schema, bool isRoot)
{
............
foreach (EA.Connector con in element.Connectors)
{
if (con.Type.ToString() == EA_Element.Aggregation.ToString() &&
con.Stereotype.ToString() == CCTS_Types.ASBIE.ToString())
{
.........
iterate(client, schema, false);
}
}
}
After :
private void iterate(EA.Element element, XmlSchema schema, bool isRoot)
{
.........
for (short a = 0; a < element.Connectors.Count; a++)
{
EA.Connector con = (EA.Connector)element.Connectors.GetAt(a);
if (con.Type.ToString() == EA_Element.Aggregation.ToString() &&
con.Stereotype.ToString() == CCTS_Types.ASBIE.ToString())
{
.........
iterate(client, schema, false);
}
}
}
Almost forget to mention, I'm using C# with .Net 2005 and Win XP sp 2.
This error occurs on version 7.0 (i forget which build) and version 7.1 (build 832 and 833) - I tested on these version, there might be a chance in other version.
Thanks in advance.