title: ReportViewer getting null error with subreport
body: <p>I'm building a small application in Visual Studio 2010 with .Net 4.0 and C# where I'm generating a ReportViewer-report from a List. I then have a subreport in my tablix that should pass a property-value from WebLink called ProviderIdentifier. I implement the SubReportProcessing-event on my report to return data to the subreport like this:</p>
  
  <pre><code>private void localReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
  {
      List&lt;WebLink&gt; links = LinkProvider.FetchSublinks(LinkProvider.Fetch(new WebLink(new Uri("http://www.contentstudio.se/"))));
      e.DataSources.Add(new ReportDataSource("ParentLinks", links));
  }
  </code></pre>
  
  <p>Currently I return the same links for all instances of the subreport. The report works fine until I try to pass a parameter to the subreport. When I add the parameter using ProviderIdentifier (which I can display in my report without problem) I always get a NullReferenceException with the message "Object reference not set to an instance of an object." when I call Render() on my LocalReport-object. The same happens if I add a static value (like 1) to the report instead of passing ProviderIdentifier. If I remove the parameter all together it works great though but I have no way to identify which links to return to the subreport.</p>
  
  <p>Anyone know what could cause this problem?</p>
  
  <p>Complete code:</p>
  
  <pre><code>public void RenderReport()
  {
      LocalReport localReport = new LocalReport
                                      {
                                          ReportPath = ("BrokenLink.rdlc"),
                                          EnableHyperlinks = true,
                                          ShowDetailedSubreportMessages = true
                                      };
  
      List&lt;WebLink&gt; links = LinkProvider.FetchSublinks(LinkProvider.Fetch(new WebLink(new Uri("http://www.contentstudio.se/"))));
  
      ReportDataSource reportDataSource = new ReportDataSource("Weblinks", links);
      localReport.DataSources.Add(reportDataSource);
  
      localReport.SubreportProcessing += localReport_SubreportProcessing;
  
      const string reportType = "PDF";
      string mimeType;
      string encoding;
      string fileNameExtension;
  
      //The DeviceInfo settings should be changed based on the reportType
      //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
      const string deviceInfo = "&lt;DeviceInfo&gt;" +
                                  "  &lt;OutputFormat&gt;PDF&lt;/OutputFormat&gt;" +
                                  "  &lt;PageWidth&gt;8.5in&lt;/PageWidth&gt;" +
                                  "  &lt;PageHeight&gt;11in&lt;/PageHeight&gt;" +
                                  "  &lt;MarginTop&gt;0.5in&lt;/MarginTop&gt;" +
                                  "  &lt;MarginLeft&gt;1in&lt;/MarginLeft&gt;" +
                                  "  &lt;MarginRight&gt;1in&lt;/MarginRight&gt;" +
                                  "  &lt;MarginBottom&gt;0.5in&lt;/MarginBottom&gt;" +
                                  "  &lt;DpiX&gt;72&lt;/DpiX&gt;" +
                                  "  &lt;DpiY&gt;72&lt;/DpiY&gt;" +
                                  "&lt;/DeviceInfo&gt;";
      Warning[] warnings;
      string[] streams;
  
      //Render the report
      byte[] renderedBytes = localReport.Render(
          reportType,
          deviceInfo,
          out mimeType,
          out encoding,
          out fileNameExtension,
          out streams,
          out warnings);
  
      File.WriteAllBytes("I:\\report.pdf", renderedBytes);
  }
  </code></pre>