title: Object with List(Of Object) in WCF. When add to Object, get NullReferenceException
body: <p>I have a DataContract as followed:</p>
  
  <pre><code>&lt;DataContract()&gt; _
  Public Class PrivateProfile
   ' This member is serialized.
  &lt;DataMember()&gt; _
  Public UserAccount As UserAccount
  &lt;DataMember()&gt; _
  Public ProfileName As String = ""
  &lt;DataMember()&gt; _
  Public Birthday As Date?
  &lt;DataMember()&gt; _
  Public Gender As Int16 = 0
  &lt;DataMember()&gt; _
  Public AboutMe As String = ""
  &lt;DataMember()&gt; _
  Public Locations As New List(Of Location)
  &lt;DataMember()&gt; _
  Public Contacts As New List(Of Contact)
  End Class
  </code></pre>
  
  <p>The Contact is:</p>
  
  <pre><code>&lt;DataContract()&gt; _
  Public Class Contact
  
  
  ' This member is serialized.
  &lt;DataMember()&gt; _
  Public Value As String
  &lt;DataMember()&gt; _
  Public ContactTypes_ContactTypeId As Int16
  &lt;DataMember()&gt; _
  Public PrivatePs As New List(Of PrivateProfile)
  
  
  End Class
  </code></pre>
  
  <p>On Client Side I use the following code:</p>
  
  <pre><code>Dim svcProfile As New svcProfiles.ProfilesClient
  .....
  
  Dim pprofile As New svcProfiles.PrivateProfile
  .....
  
  Dim co As New svcProfiles.Contact
  
          co.Value = "34234234234"
          co.ContactTypes_ContactTypeId = 1
  
          pprofile.Contacts.Add(co)
  </code></pre>
  
  <p>As soon i get to Add the contact to the Profile (last line), i get a NullReferenceException.
  Contacts is allways nothing, but i dont know why.</p>
  
  <p>Any Idea... googled a lot... </p>
  
  <p><strong>Edit:</strong>
  When i run in same situation on wcf implementation (server) side i get into same problem: </p>
  
  <pre><code>If pprofile.Contacts.Count &gt; 0 Then 
  
      Dim co As New contracts.Contact 
  
      For Each co In pprofile.Contacts 
  
          Dim con As New ef.Contact()
  
          con.ContactTypes_ContactTypeId = co.ContactTypes_ContactTypeId 
          con.Value = co.Value 
          con.PrivatePs.Add(pp) 
          context.Add(con) 
  
      Next 
  
      context.SaveChanges() 
  
  End If 
  </code></pre>