C# DevExpress 的gridControl或gridView数据导出失败解决方法

来自:http://blog.csdn.net/lybwwp/article/details/8049464

谢谢

在使用DevExpress 的GridPanel控件的时候出现了一个莫名其妙的现象,在使用ExportToXls方法导出表格到Excel的时候,在本地调试没有问题。部署到客户机上的时候问题出现了,居然没有创建文件。包括ExportToPdf、ExportToMht等都不行。google后在csdn的一片文章内(http://topic.csdn.net/u/20080303/17/76d3ded4-d43d-4c57-907a-492fce69ac27.html),发现原来是没有引用DevExpress.XtraPrinting。引用后把DevExpress.XtraPrinting.v8.3.dll文件一起部署到客户机后,问题解决。

C# DevExpress 的gridControl或gridView数据导出数据时报如下错误

有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
   在 DevExpress.XtraPrinting.ComponentPrinter.CreateLink()
   在 DevExpress.XtraPrinting.ComponentExporter.get_LinkBase()
   在 DevExpress.XtraGrid.Views.Base.BaseView.ClearDocumentIfNeeded()
   在 DevExpress.XtraGrid.Views.Base.BaseView.ExecutePrintExport(Action0 method)
   在 DevExpress.XtraGrid.Views.Base.BaseView.ExportToXls(String filePath)
   在 DevExpress.XtraGrid.GridControl.ExportToXls(String filePath)
   在 Medicine_ERP.Room_YaopinForm.barButtonItem4_ItemClick(Object sender, ItemClickEventArgs e)
   在 DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
   在 DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
   在 DevExpress.XtraBars.BarItemLink.OnLinkClick()
   在 DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
   在 DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
   在 DevExpress.XtraBars.BarItemLink.OnLinkActionCore(BarLinkAction action, Object actionArgs)
   在 DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
   在 DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
   在 DevExpress.XtraBars.Controls.CustomLinksControl.OnMouseUp(MouseEventArgs e)
   在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 DevExpress.XtraBars.Controls.DockedBarControl.WndProc(Message& msg)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** 已加载的程序集 **************
mscorlib
    程序集版本: 4.0.0.0
    Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
    基本代码: file:///C:/WINDOWS/Microsoft.NET/Framework4.0.30319/mscorlib.dll
----------------------------------------
Medicine_ERP
    程序集版本: 1.0.0.0
Win32 版本: 1.0.0.0
    基本代码: file:///C:/Program%20Files/Anshield_Medicine_ERP/Anshield_Medicine_ERP/Medicine/Medicine_ERP.exe

原文地址:https://www.cnblogs.com/gisoracle/p/5642576.html