So I am working with Silverlight a lot lately (in C# of course).

In my latest workings I have been getting an exception thrown at me, and I cannot figure out why. Maybe someone could help me figure it out.

Here is the code:

NodeDTP myNode = new NodeDTP();    

while (!myXmlReader.EOF)

	if (myXmlReader.Name == "NodeDTP" && myXmlReader.IsStartElement())
		myNode = new NodeDTP();
		try { LayoutCanvas.Children.Add(myNode); }
		catch (Exception e) 
			//throws an exception
Now, let me explain a bit. Basically I have an XML file with two "NodeDTP" elements in it. The first NodeDTP element gets read in perfectly and added to the LayoutCanvas.Children collection.

The second NodeDTP element gets read in as well, but when I try to add it to the LayoutCanvas.Children collection, a "System.InvalidArgument" exception gets thrown. This doesn't make sense because the object is not NULL, it has valid data, and it is of the exact same data type as the previous object which was just passed to the Add() function (and that previous object was accepted just fine).