title: How can I pass a read only collection to a blazor component?
body: <p>I have created a simple Blazor component (.NET Core 3.1, Blazor server apps) with a public parameter:</p>
  
  <pre><code>    [Parameter]
      public IReadOnlyCollection&lt;Resource&gt; Services { get; set; }
  </code></pre>
  
  <p>I fill this parameter from a <strong>.cshtml</strong> page:</p>
  
  <pre><code>    &lt;component type="typeof(ActivityView)" render-mode="ServerPrerendered" param-Services="Model.Services" /&gt;
  </code></pre>
  
  <p>The model property has the same type:</p>
  
  <pre><code>    public IReadOnlyCollection&lt;Resource&gt; Services { get; set; }
  </code></pre>
  
  <p>When the instance of services is a <strong>ReadOnlyCollection(Resource)</strong>, the blazor page directly runs into the following error on the client side:</p>
  
  <blockquote>
    <p>Error: The list of component records is not valid. (blazor.server.js:15)</p>
  </blockquote>
  
  <p>When the instance of services is a <strong>List(Resource)</strong>, the blazor page works perfectly fine. </p>
  
  <p>To clarify this: </p>
  
  <pre><code>    Services = someList.ToList(); // works.
      Services = someList.ToList().AsReadOnly(); // does not work
  </code></pre>
  
  <p>I could not find anything about supported objects passed to Blazor components as parameter in the MSDN documentation. Howevery, I noticed classes without a parameterless constructor seem to be not supported as well. Resource must have a parameterless constructor; otherwise I run into the same error.</p>
  
  <p>Does anyone know the reason here? The object is not used for data binding. It is only used to fill a dropdown list with values. Is this a known Blazor issue in 3.1?</p>