1,我在用TeeChart保存圖片時,髮生這麼一個異常,不知道為什麼,能幫我解決的高分迴報.
執行這行時髮生錯誤:chart.TChart.Export.ShowExportDialog(chart.TChart.Export.Image.JPEG);System.ArgumentNullException was unhandled
Message="值不能为空。\r\n参数名: item"
Source="System.Windows.Forms"
ParamName="item"
StackTrace:
在 System.Windows.Forms.ComboBox.ObjectCollection.AddInternal(Object item)
在 System.Windows.Forms.ComboBox.ObjectCollection.Add(Object item)
在 Steema.TeeChart.Editors.Export.ExportEditor.ExportEditor_Load(Object sender, EventArgs e)
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.WmShowWindow(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WmShowWindow(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.RunDialog(Form form)
在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
在 System.Windows.Forms.Form.ShowDialog()
在 Steema.TeeChart.Editors.Export.ExportEditor.ShowModal(Chart c, ExportFormat exportFmt)
在 Steema.TeeChart.Export.Exports.ShowExportDialog(ExportFormat expFmt)
在 FDC.UI.Chart.DataTransformChart.Cmd.SaveImageCommand.Start() 位置 D:\Source Code\FDC\src.v4\Applications\FDC3Chart\DataTransformChart\Cmd\SaveImageCommand.cs:行号 12
在 FDC.ToolMatching.Chart.APCSummaryChart.OnStartChartCommand(Object sender, EventArgs e) 位置 D:\Source Code\FDC\src.v4\Applications\ToolMatching\ToolMatching\Chart\APCSummaryChart.cs:行号 330
在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
在 System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ToolStrip.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 FDC.ToolMatching.ToolMatchingStarter.Main(String[] args) 位置 D:\Source Code\FDC\src.v4\Applications\ToolMatching\ToolMatching\ToolMatchingStarter.cs:行号 40
在 ToolMatching.Program.Main(String[] args) 位置 D:\Source Code\FDC\src.v4\Applications\ToolMatching\ToolMatchingOracle\Program.cs:行号 16
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
在 System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
在 System.Activator.CreateInstance(ActivationContext activationContext)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
執行這行時髮生錯誤:chart.TChart.Export.ShowExportDialog(chart.TChart.Export.Image.JPEG);System.ArgumentNullException was unhandled
Message="值不能为空。\r\n参数名: item"
Source="System.Windows.Forms"
ParamName="item"
StackTrace:
在 System.Windows.Forms.ComboBox.ObjectCollection.AddInternal(Object item)
在 System.Windows.Forms.ComboBox.ObjectCollection.Add(Object item)
在 Steema.TeeChart.Editors.Export.ExportEditor.ExportEditor_Load(Object sender, EventArgs e)
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.WmShowWindow(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WmShowWindow(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.RunDialog(Form form)
在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
在 System.Windows.Forms.Form.ShowDialog()
在 Steema.TeeChart.Editors.Export.ExportEditor.ShowModal(Chart c, ExportFormat exportFmt)
在 Steema.TeeChart.Export.Exports.ShowExportDialog(ExportFormat expFmt)
在 FDC.UI.Chart.DataTransformChart.Cmd.SaveImageCommand.Start() 位置 D:\Source Code\FDC\src.v4\Applications\FDC3Chart\DataTransformChart\Cmd\SaveImageCommand.cs:行号 12
在 FDC.ToolMatching.Chart.APCSummaryChart.OnStartChartCommand(Object sender, EventArgs e) 位置 D:\Source Code\FDC\src.v4\Applications\ToolMatching\ToolMatching\Chart\APCSummaryChart.cs:行号 330
在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
在 System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ToolStrip.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 FDC.ToolMatching.ToolMatchingStarter.Main(String[] args) 位置 D:\Source Code\FDC\src.v4\Applications\ToolMatching\ToolMatching\ToolMatchingStarter.cs:行号 40
在 ToolMatching.Program.Main(String[] args) 位置 D:\Source Code\FDC\src.v4\Applications\ToolMatching\ToolMatchingOracle\Program.cs:行号 16
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
在 System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
在 System.Activator.CreateInstance(ActivationContext activationContext)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
因此,可以猜测一下,ShowExportDialog这个函数尝试显示一导出对话框,且这个对话框包含了一个ComboBox控件,但ComboBox控件初始化不成功(尝试添加一null项)。这样,问题锁定,找到这个ComboBox(有可能是选文件名的组合框,或选文件类型的组合框。前者的可能性较大),考虑如何使其正确初始化
个人猜测应是ShowExportDialog前要指定一个初始的文件名或路径