title: Operation is not valid due to the current state of the object - Linq on List
body: <p>This error is being thrown when running a Linq query over a List.</p>
  
  <p>I am using Unity3D 3.0 with C# (Unity3D uses Mono 2.6). Unity3D, as far as I know, is single-threaded. It works by attaching "scripts" (c# .cs files) that inherit a baseclass, to a "GameObject". Also, Unity controls instantiation and serialization of scripts so you can't use constructors.</p>
  
  <p>I have a RoadNetwork script that holds a reference to RoadNodes and RoadCurves, both of which locate RoadNetwork via a singleton and register/deregister themselves. I've put "mini-factories" in RoadNode and RoadCurve that do the hard work of hooking themselves up to a gameobject.</p>
  
  <p>RoadNode first checks with RoadNetwork to make sure there isnt already a node at that same position, by doing this:</p>
  
  <pre><code>public static RoadNode2 New(float x, float y, float z)
  {
      //First try to find an existing one
      var rn = RoadNetwork.Instance.GetNodeAtPosition(new Vector3(x, y, z))
               ?? UnityReferenceHelper.GetNewGameObjectFor&lt;RoadNode2&gt;(
                   "RoadNode_" + (RoadNetwork.Instance.Nodes.Count + 1).ToString("D3"),
                   RoadNetwork.Instance.transform.FindChild("Nodes"));
  
      rn.Position = new Vector3(x, y, z);
  
      rn.gameObject.active = true;
  
      return rn;
  }
  </code></pre>
  
  <p>Where the appropriate method in RoadNetwork is:</p>
  
  <pre><code>public RoadNode2 GetNodeAtPosition(Vector3 position)
  {
      var tempList = new List&lt;RoadNode2&gt;();
  
      return tempList.Single(x =&gt; x.Position == position);
  }
  </code></pre>
  
  <p>tempList was an attempt at narrowing down the problem but I get precisely the same error. It should be "Nodes.Single(...", but I doubt it matters. I get the same error if I call the Linq query directly in the New() method.</p>
  
  <p>So yes, this Exception throws and points me to that tempList.Single() line. What would the reason be?</p>