We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cloning a document fails with NullReferenceException

I am currently evaluating DocIO and I found a problems when trying to clone a document.

The following code fails on the second line with a null reference exception:

IWordDocument templateDoc = new WordDocument(templatePath);
WordDocument saveDoc = templateDoc.Clone();

The details of the exception are:

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Syncfusion.DocIO.Base"
StackTrace:
at Syncfusion.DocIO.DLS.XmlParagraphItem.CloneImpl()
at Syncfusion.DocIO.DLS.ParagraphItemCollection.CloneItemsTo(ParagraphItemCollection items)
at Syncfusion.DocIO.DLS.WParagraph.CloneParagraph(Boolean cloneItems)
at Syncfusion.DocIO.DLS.WParagraph.CloneImpl()
at Syncfusion.DocIO.DLS.EntityCollection.CloneTo(EntityCollection destColl)
at Syncfusion.DocIO.DLS.WTextBody.CloneImpl()
at Syncfusion.DocIO.DLS.WSection.CloneImpl()
at Syncfusion.DocIO.DLS.EntityCollection.CloneTo(EntityCollection destColl)
at Syncfusion.DocIO.DLS.WordDocument.ImportContent(IWordDocument doc, Boolean importStyles)
at Syncfusion.DocIO.DLS.WordDocument..ctor(WordDocument doc)
at Syncfusion.DocIO.DLS.WordDocument.CloneImpl()
at Syncfusion.DocIO.DLS.WordDocument.Clone()
at TestMailMergeApp.frmTestMailMerge.RunMergeWithDocIO(Int32 recordCount) in C:\Users\NWhymark\Documents\Visual Studio 2008\Projects\TestMailMerge\TestMailMergeApp\frmTestMailMerge.cs:line 174
at TestMailMergeApp.frmTestMailMerge.btnRunDocIo_Click(Object sender, EventArgs e) in C:\Users\NWhymark\Documents\Visual Studio 2008\Projects\TestMailMerge\TestMailMergeApp\frmTestMailMerge.cs:line 263
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at TestMailMergeApp.Program.Main() in C:\Users\NWhymark\Documents\Visual Studio 2008\Projects\TestMailMerge\TestMailMergeApp\Program.cs:line 21
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Any help appreciated.
LJ


6 Replies

PR Poornima R Syncfusion Team February 16, 2011 06:10 AM UTC

Hi John,

Thank you for your interest in Syncfusion Products.

Could you please provide us with the template word document which you are trying to clone. So that we can analyze the exact cause of the issue and provide you with clear details.

Please let us know if you have any questions.

Regards,
Poornima



LA LaughingJohn February 16, 2011 10:16 AM UTC

Hi,

Thanks for replying, I have attached the document which is causing the problem.

Regards,
LJ



Test Letter_b76550b6.zip


PR Poornima R Syncfusion Team February 17, 2011 09:29 AM UTC

Hi John,

Thank you for your update.

We were able to reproduce the mentioned issue. We suspect this could be a defect. We have forwarded this issue to our development team for further analysis.

Could you please report this issue through Direct Trac Developer Support System
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents because you can take the advantage of the expertise of a dedicated support engineer and a guaranteed response time and we hope you will take advantage of this system
as well. If you have already reported, please ignore this.

Please let me know if you have any questions.

Regards,
Poornima



JM Jonathan McIlwaine June 6, 2011 03:59 PM UTC


Hello,

this issue (#4698) seems to be corrected in Version 8.3.0.21. but we still have the problem.

Our Syncfusion.DocIO.Base.dll Version : 8.403.0.10

Regards.



JM Jonathan McIlwaine June 8, 2011 07:58 AM UTC

Hi,
i would like to add an update to my post, it's not the cloning of a document which raise an error, it's a section in the document.
sorry.

Regards



PR Poornima R Syncfusion Team June 9, 2011 08:28 AM UTC

Hi Ferdinand,

Thank you for your update.

The mentioned “Null reference” exception issue has been fixed in our latest version 9.2.0.137 that is rolled out and available for download under the below location. Please try upgrading to our latest version and let us know if this helps you.


http://www.syncfusion.com/support/forums/general/99216/Essential-Studio-2011-Volume-2-Final-Release-v920137-available-for-download


Please let us know if you have any questions.

Regards,
Poornima



Loader.
Live Chat Icon For mobile
Up arrow icon