However, without any changes to my code, other than the references, which are handled by NuGet, the load now fails. The versions should be the same, I would think, other than the stamp at the top and the restrictions placed on the two versions. With regard to basic functionality, they should be identical. The two versions are inconsistent, and that greatly concerns me, from an evaluation perspective.
Here is my code:
- Code: Select all
Document thisdoc = new Document();
thisdoc.LoadFromFile(TemplateFileName);
The TemplateFileName variable comes into the method as a string, but originally comes from a document that is loaded into memory from the database in the calling method.
I originally had this in a using statement:
- Code: Select all
using (Spire.Doc.Document thisdoc = new Document(TemplateFileName.ToString()))
In that case, the TemplateFileName came in as an object, thus the ToString() usage.
In both cases, I verified that the value of TemplateFileName is:
"C:\\Projects\\AirTools\\trunk\\AirTools\\AirToolsWin\\bin\\x86\\Debug\\ACC Acceptance Letter Template__743667__857338.DOCX"
When I attempt to run the routine, it throws the NullReferenceException, attached below, using either format. However, if I return to the Spire.Doc version, it works as it should. This only happens in FreeSpire.Doc
Here is the error detail:
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Spire.Doc
StackTrace:
at spr1503.14(XmlReader A_0, ParagraphItemCollection A_1)
at spr1503.14(XmlReader A_0, IDocumentObject A_1)
at spr1503.13(Stream A_0)
at spr1503.1(spr395 A_0)
at spr1503.1(Document A_0)
at spr1503.1(Stream A_0, Document A_1)
at spr1503.0(String A_0, Document A_1)
at Spire.Doc.Document.16(String A_0)
at Spire.Doc.Document.LoadFromFile(String fileName, FileFormat fileFormat, String password)
at Spire.Doc.Document.0(String A_0, String A_1)
at Spire.Doc.Document.LoadFromFile(String fileName)
at AirToolsWin.Globals.CreateDocFromTemplate(String TemplateFileName, Dictionary`2 repList) in C:\Projects\AirTools\trunk\AirTools\AirToolsWin\Globals.cs:line 909
at AirToolsWin.Globals.GenerateLetter(String category, String type_code, clsAttach ca, DataSet ds) in C:\Projects\AirTools\trunk\AirTools\AirToolsWin\Globals.cs:line 852
at AirToolsWin.frmSubmittedReport.miPrintLetter_ItemClick(Object sender, EventArgs e) in C:\Projects\AirTools\trunk\AirTools\AirToolsWin\frmSubmittedReport.cs:line 835
at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarButtonItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarItemLink.OnLinkClick()
at DevExpress.XtraBars.BarButtonItemLink.OnLinkClick()
at DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
at DevExpress.XtraBars.Controls.CustomLinksControl.OnMouseUp(MouseEventArgs e)
at DevExpress.XtraBars.Controls.CustomPopupBarControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at DevExpress.XtraBars.Controls.CustomControl.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(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(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 System.Windows.Forms.Application.Run(Form mainForm)
at AirToolsWin.frmMain.Main(String[] args) in C:\Projects\AirTools\trunk\AirTools\AirToolsWin\frmMain.cs:line 60
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
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:
Any assistance with this issue would be appreciated.
John