title: C# Serialization: save List with objects of type Action to file
body: <p>I have problem with serialization.</p>
  
  <p>My list look like :</p>
  
  <pre><code> public List&lt;Action&gt; functions = new List&lt;Action&gt;();
  </code></pre>
  
  <p>Later i just add objects to list by :</p>
  
  <pre><code>functions.Add(waypoint1);
  </code></pre>
  
  <p>my button to serialize look like :</p>
  
  <pre><code> private async void metroButton8_Click(object sender, EventArgs e) // save wpts button
          {
              string dir = @"c:\temp";
              string serializationFile = Path.Combine(dir, "wpts.bin");
              //serialize
              using (Stream stream = File.Open(serializationFile, FileMode.Create))
              {
                  var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
  
                  bformatter.Serialize(stream, functions);
              }
  
          }
  
  
  void Waypoint1()
  {
  Console.WriteLine("Im first waypoint");
  }
  </code></pre>
  
  <p>When i try just save to file i have an error:
  An exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll but was not handled in user code</p>
  
  <p>What should i add here just don't know searches a lot of forums and still don't know. Please be patient for newbies in c#.
  Thanks!</p>