Skip to Content
Former Member
Jun 16, 2009 at 10:48 AM

Add comments result in 'Buffer too small for string or missing null byte'


When I fill the SummaryInfo.ReportComments property of the ReportDocument object with a string, an COMException occurs: 'Buffer too small for string or missing null byte'.

This is the code:

private CrystalDecisions.CrystalReports.Engine.ReportDocument _ReportDoc;
_ReportDoc = new ReportDocument();
var reportInfo = new ReportInfo();
reportInfo.Id = 1000
... (etc).

var infoXml = string.Empty;
var xmlSer = new XmlSerializer(typeof(ReportInfo));
var writer = new StringWriter(CultureInfo.InvariantCulture);
xmlSer.Serialize(writer, reportInfo);
infoXml = writer.ToString();
 // COMException on following line.
writer.Close();ReportDoc.SummaryInfo.ReportComments = infoXml;

Variable infoXml (of type string) looks something like this:

<?xml version="1.0" encoding="utf-16"?>
<ReportInfo xmlns:xsi=""

ReportInfo class:

   public class ReportInfo
      public long Id { get; set; }
      public Guid ProdigyKey { get; set; }
      public long TemplateCategoryId { get; set; }
      public string Name { get; set; }
      public long Number { get; set; }
      public string Description { get; set; }
      public bool IsDashboardItem { get; set; }
      public Collection<long> Entities {
         get {
            if (_Entities == null) {
               _Entities = new Collection<long>();
            return _Entities;
      private Collection<long> _Entities;

I do not think the message is to big because when I paste the result string directly in a report summary using Crystal Reports, it 'fits'.