【问题标题】:System.ArgumentNullException' occurred in PresentationFramework.dll在 PresentationFramework.dll 中发生 System.ArgumentNullException'
【发布时间】:2018-02-13 11:37:46
【问题描述】:

当我尝试打印水晶报表时出现此错误。

在 PresentationFramework.dll 中发生 System.ArgumentNullException'

我正在尝试构建一个WPF 应用程序, 我以另一种形式使用了相同的代码,并且在那里运行良好。 但在此页面上显示错误。

private void btnReciept_Click(object sender, RoutedEventArgs e)
{
    try {
        if (txtComplainNo.Text == "")
        {
            ModernDialog.ShowMessage("Enter Complain Number","ErrorFound", MessageBoxButton.OK);
        }
        else
        {
            InsertFinalReport();
            var ConString = System.Configuration.ConfigurationManager.ConnectionStrings["GalaxyApp.Properties.Settings.ConnString"].ConnectionString;
            string CmdString = string.Empty;
            SqlCommand cmd = new SqlCommand();
            SqlDataAdapter MyDA = new SqlDataAdapter();
            DataSet myDS = new DataSet(); 
            // DataSet1 myDS = new DataSet1();
            SqlConnection con = new SqlConnection(ConString);
            cmd.Connection = con;
            cmd.CommandText = "Select * from FinalReport where ComplainNo='" + Convert.ToInt32(txtComplainNo.Text) + "'";
            cmd.CommandType = System.Data.CommandType.Text;
            MyDA.SelectCommand = cmd;
            MyDA.Fill(myDS, "FinalReport");
            // FinalReportDS myDS = new FinalReportDS();
            // myDS.EnforceConstraints=false;
            if (myDS.Tables[0].Rows.Count == 0)
            {
                ModernDialog.ShowMessage("EmptyDataSet", "ErrorFound", MessageBoxButton.OK);
            }
            else
            {
                CourierReport1 rpt = new CourierReport1();
                rpt.SetDataSource(myDS);
                FinalReportViewer FRV = new FinalReportViewer();
                FRV.ReportViewer.ViewerCore.ReportSource = rpt;
                FRV.Show();
            }
            //Report frm1 = new Report();
            //frm1.ReportViewer1.ViewerCore.ReportSource = rpt;
            //frm1.Show();
            ///*
            //Form1 mform = new Form1();
            //mform.ShowReport(Convert.ToInt32(txtComplainNo.Text));
            //mform.Show();
            //*/
        }
    }
    catch(Exception ex)
    {
        ModernDialog.ShowMessage(ex.Message, "ErrorFound", MessageBoxButton.OK);
    }
}

我尝试了所有替代代码。 请任何人都可以帮助我找到此错误的原因

堆栈跟踪:

   at System.Windows.Interop.WindowInteropHelper..ctor(Window window)
   at System.Windows.MessageBox.Show(Window owner, String messageBoxText, String caption, MessageBoxButton button, MessageBoxImage icon)
   at SAPBusinessObjects.WPF.Viewer.ViewerCore.HandleExceptionEvent(Object eventSource, Exception e, Boolean suppressMessage)
   at SAPBusinessObjects.WPF.Viewer.ReportAlbum.OnHandleException(Exception e)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   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 MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at GalaxyApp.App.Main() in D:\GoogleDrive\extra\GalaxyApp\GalaxyApp\obj\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
   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()
Stack Trace:

【问题讨论】:

  • 请发布所有异常详细信息。您将 null 传递给某个函数或构造函数。
  • 我发了图片你也可以看看
  • @SudhirSolka 这是水晶报告吗?看起来很像,如果是这样,请将标签添加到您的问题中。
  • @Blacktempel 我标记了它,因为它也有水晶报告
  • @SudhirSolka 对问题的评论并不表示此人能够帮助您解决特定问题。 在这种情况下,它可以帮助那些试图帮助你的人。

标签: c# crystal-reports business-objects


【解决方案1】:

CrystalReports 中的一个小“错误”是在某些情况下不显示任何有用的异常详细信息。我最近也遇到过。

这个问题很难找到,因为这个异常基本上什么也没说……而且问题也可能在报告中,而不是代码本身。
如果有任何问题,您将不得不调试并检查您的报告。

检查所有细节。
检查使用的数据库表和列...

我遇到了问题,子报表有几个参数,父报表也有。但是这些并没有自动传递给子报告。有必要为报告提供所有必需的参数。也许这对你也有帮助。遗憾的是,如果没有报告、代码和环境,这很难说。

【讨论】:

    【解决方案2】:

    特别感谢@Blacktempe 让我将此问题标记为水晶报告的每一个人,我从该线程Crystal Reports - Value cannot be null. Parameter name: window 中找到了答案?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-18
      • 2013-04-21
      • 2011-01-05
      • 1970-01-01
      相关资源
      最近更新 更多