• <tfoot id='uaAYM'></tfoot>
    1. <i id='uaAYM'><tr id='uaAYM'><dt id='uaAYM'><q id='uaAYM'><span id='uaAYM'><b id='uaAYM'><form id='uaAYM'><ins id='uaAYM'></ins><ul id='uaAYM'></ul><sub id='uaAYM'></sub></form><legend id='uaAYM'></legend><bdo id='uaAYM'><pre id='uaAYM'><center id='uaAYM'></center></pre></bdo></b><th id='uaAYM'></th></span></q></dt></tr></i><div id='uaAYM'><tfoot id='uaAYM'></tfoot><dl id='uaAYM'><fieldset id='uaAYM'></fieldset></dl></div>

        <small id='uaAYM'></small><noframes id='uaAYM'>

          <bdo id='uaAYM'></bdo><ul id='uaAYM'></ul>
      1. <legend id='uaAYM'><style id='uaAYM'><dir id='uaAYM'><q id='uaAYM'></q></dir></style></legend>

        Crystal Reports - 值不能为空.参数名称:窗口

        时间:2023-07-09

              <tfoot id='glaK2'></tfoot>
              <i id='glaK2'><tr id='glaK2'><dt id='glaK2'><q id='glaK2'><span id='glaK2'><b id='glaK2'><form id='glaK2'><ins id='glaK2'></ins><ul id='glaK2'></ul><sub id='glaK2'></sub></form><legend id='glaK2'></legend><bdo id='glaK2'><pre id='glaK2'><center id='glaK2'></center></pre></bdo></b><th id='glaK2'></th></span></q></dt></tr></i><div id='glaK2'><tfoot id='glaK2'></tfoot><dl id='glaK2'><fieldset id='glaK2'></fieldset></dl></div>
                <bdo id='glaK2'></bdo><ul id='glaK2'></ul>
              • <small id='glaK2'></small><noframes id='glaK2'>

                  <legend id='glaK2'><style id='glaK2'><dir id='glaK2'><q id='glaK2'></q></dir></style></legend>
                    <tbody id='glaK2'></tbody>

                  本文介绍了Crystal Reports - 值不能为空.参数名称:窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我最近在尝试通过对话框将水晶报表表单加载到我的 WPF 应用程序时遇到一个不寻常的错误,该报表将显示为加载几秒钟,然后抛出一个错误,指出值不能为空. 参数名称:window"

                  I recently came across an unusual error when attempting to load a crystal report form into my WPF application via a dialog, the report would show as loading for a few seconds and then throw an error stating "Value cannot be null. Parameter name: window"

                  这让我很困惑,据我所知,水晶报表不使用名为 window 的参数.

                  This confused me, as far as i know, crystal reports doesn't use a parameter named window.

                  这是我的代码:

                  带有 CrystalReportsViewer

                  <Window x:Class="Client.Views.ReportsWindowView"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:my="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer"
                      Title="ReportsWindowView" Height="300" Width="300" Loaded="Window_Loaded">
                  <Grid>
                      <my:CrystalReportsViewer ShowOpenFileButton="True" Grid.Column="1" x:Name="ReportView"/>
                  </Grid>
                  

                  并从后面的代码中加载报告(为简单起见,我删除了标准的 ConnectionInfo 代码)

                  and loading the report from code behind (I've removed the standard ConnectionInfo code for simplicity)

                   cryRpt = new ReportDocument();
                   cryRpt.Load("report.rpt");
                   ReportView.ViewerCore.ReportSource = cryRpt;
                  

                  推荐答案

                  原来Crystal Reports在尝试显示内部错误时确实使用了一个名为window的参数.

                  Turns out that Crystal Reports Does indeed use a parameter named window, when it attempts to show an internal error.

                  CrystalReportsViewer 处理内部错误并尝试显示 MessageBox:

                  CrystalReportsViewer handles internal an error and will try to show a MessageBox:

                  System.Windows.MessageBox.Show(Window owner, String messageBoxText, String caption, MessageBoxButton button, MessageBoxImage icon)

                  Show方法获取u201CWindow owneru201D参数,CrystalReportsViewer尝试传递Owner属性CrystalReportsViewer.Owner,但是默认情况下owner为null,所以出现这个意外错误.

                  Show method get u201CWindow owneru201D parameter and CrystalReportsViewer tries pass Owner property CrystalReportsViewer.Owner, however by default owner is null, as such we get this unexpected error.

                  一个简单的解决方法是在代码隐藏中(即使使用 mvvm),我们只需通过以下代码将所有者设置为当前窗口:

                  A simple fix for this, is in the codebehind (even when using mvvm) we simply set the owner to the current window via the following code:

                  ReportView.Owner = Window.GetWindow(this);
                  

                  在 OnLoaded 事件或类似事件中执行此操作,您会发现现在您会收到一个消息框,其中包含 CrystalReportsViewer 引发的内部错误.

                  Do this in the OnLoaded Event or similar, and you will find that now you get a messagebox with an internal error thrown by CrystalReportsViewer.

                  此解决方案的功劳属于此线程

                  Credit for this solution belongs to this thread

                  这篇关于Crystal Reports - 值不能为空.参数名称:窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:清理 Crystal Reports ReportDocument 对象使用的资源的最佳方法是什么? 下一篇:如何将多个报告附加在一起?

                  相关文章

                  1. <tfoot id='5mSzN'></tfoot>
                    <i id='5mSzN'><tr id='5mSzN'><dt id='5mSzN'><q id='5mSzN'><span id='5mSzN'><b id='5mSzN'><form id='5mSzN'><ins id='5mSzN'></ins><ul id='5mSzN'></ul><sub id='5mSzN'></sub></form><legend id='5mSzN'></legend><bdo id='5mSzN'><pre id='5mSzN'><center id='5mSzN'></center></pre></bdo></b><th id='5mSzN'></th></span></q></dt></tr></i><div id='5mSzN'><tfoot id='5mSzN'></tfoot><dl id='5mSzN'><fieldset id='5mSzN'></fieldset></dl></div>

                    <small id='5mSzN'></small><noframes id='5mSzN'>

                    1. <legend id='5mSzN'><style id='5mSzN'><dir id='5mSzN'><q id='5mSzN'></q></dir></style></legend>
                        <bdo id='5mSzN'></bdo><ul id='5mSzN'></ul>