I have written a very simple application to remove the comments from a word document using the free edition.
If I remove all the comments from a file, then try and repeat the process I get a NullReference Exception in the Spire.Doc.dll when loading the file for the second time.
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Spire.Doc
StackTrace:
at sprᲑ.ᜏ(XmlReader A_0, ParagraphItemCollection A_1)
at sprᲑ.ᜐ(XmlReader A_0, ParagraphItemCollection A_1)
at sprᲑ.ᜎ(XmlReader A_0, IDocumentObject A_1)
at sprᲑ.ᜍ(Stream A_0)
at sprᲑ.ᜁ(sprᡵ A_0)
at sprᲑ.ᜁ(Document A_0)
at sprᲑ.ᜀ(String A_0, Document A_1)
at Spire.Doc.Document.ᜌ(String A_0)
at Spire.Doc.Document.LoadFromFile(String fileName, FileFormat fileFormat, String password)
at Spire.Doc.Document.ᜀ(String A_0, String A_1)
at Spire.Doc.Document.LoadFromFile(String fileName)
at ClearWordComments.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\Darren\Documents\Visual Studio 2013\Projects\ClearWordComments\ClearWordComments\Form1.cs:line 26
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.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(IntPtr 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 ClearWordComments.Program.Main() in c:\Users\Darren\Documents\Visual Studio 2013\Projects\ClearWordComments\ClearWordComments\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
If I load and make a small change in MS Word and repeat the process and it all works.