title: Serialization error while publishing the content using DD4T TBB's
body: <p>We rebuilt the DD4T TBBs from source control and deployed them to tridion using TCMUploadAssembly.exe.</p>
  
  <p>We Created a simple component with a multimedia link field ,a component link field and a text field and populated the values.  Then created a CT with [Generate dynamic component, Publish binaries for component ] TBB’s inside it  and tried to publish a single DCP.</p>
  
  <p>We are able to run the CT against component in template builder and get the expected output [ i.e well formatted Serialized component XML output]  </p>
  
  <p>However when publishing we get a serialization error.  (see below) . This error is occurring while the code is trying to serialize any component field (text/multimedia/component link etc)</p>
  
  <p>We are unable to identify the root cause. Tried to remote debug the code , even though all the dynamic.component object properties are correctly set while serializing the component object we are facing this issue. Even tried to restart COM +, publisher services but issue still persists. Any pointers is highly appreciated.</p>
  
  <p><strong>Couldn’t able to find why the code is running correctly in Template builder without serialization errors but failing at publish time with below error.</strong></p>
  
  <p>Here’s the error message:</p>
  
  <blockquote>
    <p>There was an error generating the XML document.</p>
    
    <p>There was an error generating the XML document.</p>
    
    <p>Object reference not set to an instance of an object.</p>
    
    <p>Component: Templating</p>
    
    <p>Errorcode: 0</p>
    
    <p>User: NORD\DWTMTSUser</p>
    
    <p>StackTrace Information Details:</p>
    
    <p>at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterField.XSArrayInfo.get_Item(Object a, Int32 i)</p>
    
    <p>at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterField.Write13_Field(String n, String ns, Object o, Boolean isNullable, Boolean needType)</p>
    
    <p>at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterField.Write14_Field(Object o)</p>
    
    <p>at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)</p>
    
    <p>at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o)</p>
    
    <p>at DD4T.ContentModel.SerializableDictionary`3.WriteXml(XmlWriter writer) in D:\DW-Source\Mainline\Src\DD4T\DD4T.ContentModel\SerializableDictionary.cs:line 80</p>
    
    <p>at System.Xml.Serialization.XmlSerializationWriter.WriteSerializable(IXmlSerializable serializable, String name, String ns, Boolean isNullable, Boolean wrapped)</p>
    
    <p>at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write13_Component(String n, String ns, Component o, Boolean isNullable, Boolean needType) in :line 0</p>
    
    <p>at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write32_Component(Object o) in :line 0</p>
    
    <p>at Microsoft.Xml.Serialization.GeneratedAssembly.ComponentSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer) in :line 0</p>
    
    <p>at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)</p>
    
    <p>at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)</p>
    
    <p>at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle)</p>
    
    <p>at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces)</p>
    
    <p>at DD4T.Templates.Base.BaseComponentTemplate.Transform(Engine engine, Package package) in D:\DW-Source\Mainline\Src\DD4T\DD4T.Templates.Base\BaseComponentTemplate.cs:line 88</p>
    
    <p>at Tridion.ContentManager.Templating.Assembly.AssemblyMediator.Transform(Engine engine, Template template, Package package)</p>
    
    <p>at Tridion.ContentManager.Templating.Assembly.CSharpSourceCodeMediator.RunTemplate(Engine engine, Package package, String templateUri, String className)</p>
    
    <p>at Tridion.Templating.CSharpTemplate.CSharpSourceTemplate.Transform(Engine __engine, Package __package)</p>
    
    <p>at Tridion.ContentManager.Templating.Assembly.CSharpSourceCodeMediator.Transform(Engine engine, Template template, Package package)</p>
    
    <p>at Tridion.ContentManager.Templating.Engine.ExecuteTemplate(Template template, Package package)</p>
  </blockquote>