Click here to Skip to main content
15,914,924 members
Home / Discussions / C#
   

C#

 
QuestionDNS Resolve problem in .NET 2.0??? Pin
gman4411-Feb-06 9:36
gman4411-Feb-06 9:36 
AnswerRe: DNS Resolve problem in .NET 2.0??? Pin
spirit_of_pak12-Feb-06 17:36
spirit_of_pak12-Feb-06 17:36 
GeneralRe: DNS Resolve problem in .NET 2.0??? Pin
gman4413-Feb-06 3:16
gman4413-Feb-06 3:16 
QuestionConditional Property Setters (friends in C#) Pin
Marc Clifton11-Feb-06 8:00
mvaMarc Clifton11-Feb-06 8:00 
AnswerRe: Conditional Property Setters (friends in C#) Pin
Kevin McFarlane11-Feb-06 8:45
Kevin McFarlane11-Feb-06 8:45 
AnswerRe: Conditional Property Setters (friends in C#) Pin
StealthyMark14-Feb-06 6:12
StealthyMark14-Feb-06 6:12 
QuestionHow can i disable temporarily warnings/error from the code? Pin
e-laj11-Feb-06 7:41
e-laj11-Feb-06 7:41 
AnswerRe: How can i disable temporarily warnings/error from the code? Pin
Kevin McFarlane11-Feb-06 8:43
Kevin McFarlane11-Feb-06 8:43 
GeneralRe: How can i disable temporarily warnings/error from the code? Pin
e-laj11-Feb-06 12:02
e-laj11-Feb-06 12:02 
GeneralRe: How can i disable temporarily warnings/error from the code? Pin
Kevin McFarlane11-Feb-06 12:20
Kevin McFarlane11-Feb-06 12:20 
AnswerRe: How can i disable temporarily warnings/error from the code? Pin
Wayne Phipps11-Feb-06 8:43
Wayne Phipps11-Feb-06 8:43 
AnswerRe: How can i disable temporarily warnings/error from the code? Pin
Dave Kreskowiak11-Feb-06 8:51
mveDave Kreskowiak11-Feb-06 8:51 
GeneralRe: How can i disable temporarily warnings/error from the code? Pin
e-laj11-Feb-06 11:59
e-laj11-Feb-06 11:59 
Questionenumeration was modified operation may not execute Pin
spirit_of_pak11-Feb-06 6:23
spirit_of_pak11-Feb-06 6:23 
AnswerRe: enumeration was modified operation may not execute Pin
Ravi Bhavnani11-Feb-06 6:38
professionalRavi Bhavnani11-Feb-06 6:38 
AnswerRe: enumeration was modified operation may not execute Pin
perlmunger11-Feb-06 6:45
perlmunger11-Feb-06 6:45 
Try this instead:
private void CloseOldForms()
{
	FormCollection frmColl = Application.OpenForms;

	foreach ( int i = 0; i < frmColl.Count; ++i )
	{
		Form tempFrm = frmColl[i];
		string tempFrmTxt = tempFrm.Tag.ToString();
		if (tempFrmTxt.Equals("NOTMAIN"))
		{
			tempFrm.Close();
		}
	}
}

I'm not absolutely sure of this, but I think that when you call Close on your form, it is attempting to remove the form object from the form collection automatically which is what causes this error since you are at that point in effect trying to alter the contents of the collection over which you are iterating.

Hope that helps.

-Matt

------------------------------------------

The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
GeneralRe: enumeration was modified operation may not execute Pin
Dave Kreskowiak11-Feb-06 8:46
mveDave Kreskowiak11-Feb-06 8:46 
GeneralRe: enumeration was modified operation may not execute Pin
perlmunger11-Feb-06 11:10
perlmunger11-Feb-06 11:10 
AnswerRe: enumeration was modified operation may not execute Pin
malharone11-Feb-06 7:31
malharone11-Feb-06 7:31 
GeneralRe: enumeration was modified operation may not execute Pin
Colin Angus Mackay11-Feb-06 13:41
Colin Angus Mackay11-Feb-06 13:41 
GeneralRe: enumeration was modified operation may not execute Pin
malharone11-Feb-06 18:14
malharone11-Feb-06 18:14 
GeneralRe: enumeration was modified operation may not execute Pin
Colin Angus Mackay12-Feb-06 1:34
Colin Angus Mackay12-Feb-06 1:34 
GeneralRe: enumeration was modified operation may not execute Pin
malharone12-Feb-06 5:27
malharone12-Feb-06 5:27 
GeneralRe: enumeration was modified operation may not execute Pin
spirit_of_pak12-Feb-06 17:28
spirit_of_pak12-Feb-06 17:28 
QuestionError Pin
NaNg1524111-Feb-06 3:54
NaNg1524111-Feb-06 3:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.