c# Add to list null reference (instance of list exists)
<p>Im trying to add objects called Process to the list. It returns a null reference exception when I try to add items to the list. (lijst.Add) </p>

<p>I search the net and find mostly answers like: you dont have instantiated the list. Well here it is instantiated so what could be wrong with this code? All other variables are filled correctly. </p>

<p>This is the code:</p>

<pre><code>private List&lt;Process&gt; CreateProcessFromXml()
    { 
        List&lt;Process&gt; lijst = new List&lt;Process&gt;();

        var path = Path.Combine(Server.MapPath("~/App_Data"), "Process.xml");
        XDocument process = XDocument.Load(path);
        var elementen = XElement.Load(path);
        foreach (var element in elementen.Elements("Proces"))
        {
            lijst.Add(
                new Process
                {
                    Naam = element.Element("Naam").Value,
                    TemplatePath = element.Element("TemplatePath").Value,
                    OutputPath = element.Element("OutPutPath").Value,
                    OutputDocumentName = element.Element("OutputDocumentName").Value
                });
        }
        return lijst;
    }
</code></pre>

<p>Process class:</p>

<pre><code>public class Process
{
    public string Naam { get; set; }
    public string TemplatePath { get; set; }
    public string OutputPath { get; set; }
    public string OutputDocumentName { get; set; }
}
</code></pre>

<p>Exception tekst:</p>

<p>Line 34:             foreach (var element in elementen.Elements("Proces"))</p>

<p>Line 35:             {</p>

<p>Line 36:                 <strong>lijst.Add(new Process</strong> (in red)</p>

<p>Line 37:                 {</p>

<p>Line 38:                     Naam = element.Element("Naam").Value,</p>

<p>Source File: xxxxxxxx    Line: 36 </p>

<p>Stack Trace: </p>

<p>[NullReferenceException: Object reference not set to an instance of an object.]</p>

<pre><code>XML: &lt;Proces&gt;
    &lt;Naam&gt;
    &lt;/Naam&gt;
    &lt;TemplatePath&gt;
    &lt;/TemplatePath&gt;
    &lt;OutputPath&gt;
    &lt;/OutputPath&gt;
    &lt;OutputDocumentName&gt;
    &lt;/OutputDocumentName&gt;
  &lt;/Proces&gt;
</code></pre>

<p>Thanks in advance.</p>