title: How to find out what exactly is causing a NullReferenceException
body: <p>So I'm making an application, and everything is running great, until the following happens:</p>
  
  <p><img src="https://i.stack.imgur.com/9Jwam.png" alt="NullReferenceException"></p>
  
  <p>I have checked through the debugger but I can't find exactly what is causing this exception. I have a feeling that the root cause is on the SQL side of things, as that is the only part that I have changed recently, but I need to know exactly where the <code>NullReferenceException</code> is in order to know what SQL code to fix.</p>
  
  <p>Here is a stack trace, if that helps (I don't expect you guys to know exactly what is causing the <code>NullReferenceException</code>, I just can't seem to find it and I'm completely lost):</p>
  
  <pre><code>[NullReferenceException: Object reference not set to an instance of an object.]
     iTextSharp.text.pdf.PdfPRow.CopyContent(PdfPRow copy) +124
     iTextSharp.text.pdf.ColumnText.GoComposite(Boolean simulate) +8178
     iTextSharp.text.pdf.ColumnText.Go(Boolean simulate) +203
     iTextSharp.text.pdf.ColumnText.Go() +33
     iTextSharp.text.pdf.PdfDocument.AddPTable(PdfPTable ptable) +426
     iTextSharp.text.pdf.PdfDocument.Add(IElement element) +7594
     iTextSharp.text.Document.Add(IElement element) +394
     BigYOperationsConsole.Helpers.PdfHelper.ChecklistPdfStream(Checklist cl) in C:\workspace\BigYOperationsConsole\Helpers\PdfHelper.cs:129
     BigYOperationsConsole.Controllers.ChecklistsController.ExportPDF(Int32 id) in C:\workspace\BigYOperationsConsole\Controllers\ChecklistsController.cs:776
     lambda_method(Closure , ControllerBase , Object[] ) +150
     System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +51
     System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +409
     System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +52
     System.Web.Mvc.&lt;&gt;c__DisplayClass15.&lt;InvokeActionMethodWithFilters&gt;b__12() +127
     System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +436
     System.Web.Mvc.&lt;&gt;c__DisplayClass17.&lt;InvokeActionMethodWithFilters&gt;b__14() +61
     System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +305
     System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +830
     System.Web.Mvc.Controller.ExecuteCore() +136
     System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +232
     System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +39
     System.Web.Mvc.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +68
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +44
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8`1.&lt;BeginSynchronous&gt;b__7(IAsyncResult _) +42
     System.Web.Mvc.Async.WrappedAsyncResult`1.End() +141
     System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +54
     System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
     System.Web.Mvc.&lt;&gt;c__DisplayClasse.&lt;EndProcessRequest&gt;b__d() +61
     System.Web.Mvc.SecurityUtil.&lt;GetCallInAppTrustThunk&gt;b__0(Action f) +31
     System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +56
     System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +110
     System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +690
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +194
  </code></pre>
  
  <p><strong>Update:</strong> This appears to be a bug with colspans in iTextSharp 5.0.6. I upgraded to 5.1.1 and everything appears to be working just fine now. See my comments below for more details. The strange part is that everything was working with 5.0.6 ...</p>