CrystalReportsViewer调试错误消息

时间:2017-02-08 17:00:21

标签: c# wpf crystal-reports

我在使用VS 2015的WPF应用程序中加入了CrystalReportsViewer。这是我的视图:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:KnoxFactoryLoader.Views"
    xmlns:Viewer="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer" ToolTip="Production Batch Report" x:Name="ProductionBatch" x:Class="KnoxFactoryLoader.Views.Report_View"
    mc:Ignorable="d"
    WindowStartupLocation="CenterScreen"    
    Title="Production Batch Report View" Height="600" Width="700">
    <Viewer:CrystalReportsViewer Name="rptView" ShowLogo="False" ShowToolbar="True" ShowToggleSidePanelButton="False"
       ToggleSidePanel="None" Focusable="True" ShowOpenFileButton="False" 
                                 ShowCopyButton="False"  ShowRefreshButton="False" 
       HorizontalAlignment="Left" VerticalAlignment="Top"/>
   </Window>

这是我背后的代码:

public partial class Report_View : Window
{
    public Report_View(string param1, string reportName)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        reportDocument.Load(reportName);
        CrystalDecisions.CrystalReports.Engine.Tables CrTables;
        CrystalDecisions.Shared.TableLogOnInfo crtableLogoninfo = new CrystalDecisions.Shared.TableLogOnInfo();
        CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
        crConnectionInfo.ServerName = "ServerName1";
        crConnectionInfo.DatabaseName = "DatabaseName1";
        crConnectionInfo.UserID = "user1";
        crConnectionInfo.Password = "pass1";

        CrystalDecisions.Shared.TableLogOnInfo crtableLogoninfo2 = new CrystalDecisions.Shared.TableLogOnInfo();
        CrystalDecisions.Shared.ConnectionInfo crConnectionInfo2 = new CrystalDecisions.Shared.ConnectionInfo();
        crConnectionInfo2.ServerName = "ServerName2";
        crConnectionInfo2.DatabaseName = "DatabaseName2";
        crConnectionInfo2.UserID = "user2";
        crConnectionInfo2.Password = "pass2";

        CrTables = reportDocument.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
        {
            if (CrTable.Name.Equals("TABLE1"))
            {
                crtableLogoninfo2 = CrTable.LogOnInfo;
                crtableLogoninfo2.ConnectionInfo = crConnectionInfo2;
                CrTable.ApplyLogOnInfo(crtableLogoninfo2);
            }
            else
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }
        }
        reportDocument.SetParameterValue("Param1", param1);
        InitializeComponent();
        rptView.ViewerCore.ReportSource = reportDocument;
        var viewer = rptView as SAPBusinessObjects.WPF.Viewer.CrystalReportsViewer;
        if (viewer != null)
        {
            viewer.Focusable = true;
            viewer.Focus();
        }
    }

创建的报告是正确的。但是,有很多调试错误消息。

System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;按钮&#39; (名称=&#39; btnOpen&#39);目标元素是&#39;按钮&#39; (名称=&#39; btnOpen&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;) System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;按钮&#39; (名称=&#39; btnPrint&#39);目标元素是&#39;按钮&#39; (名称=&#39; btnPrint&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;) System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;按钮&#39; (名称=&#39; btnRefresh&#39);目标元素是&#39;按钮&#39; (名称=&#39; btnRefresh&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;) System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;按钮&#39; (名称=&#39; btnExport&#39);目标元素是&#39;按钮&#39; (名称=&#39; btnExport&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;) System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;按钮&#39; (名称=&#39; btnCopy&#39);目标元素是&#39;按钮&#39; (名称=&#39; btnCopy&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;) System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;切换按钮&#39; (名称=&#39; btnToggleSidePanel&#39);目标元素是&#39; ToggleButton&#39; (名称=&#39; btnToggleSidePanel&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;) System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;按钮&#39; (名称=&#39; btnPrevPage&#39);目标元素是&#39;按钮&#39; (名称=&#39; btnPrevPage&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;) System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;按钮&#39; (名称=&#39; btnNextPage&#39);目标元素是&#39;按钮&#39; (名称=&#39; btnNextPage&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;) System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;按钮&#39; (名称=&#39;&#39);目标元素是&#39;按钮&#39; (名称=&#39;&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;) System.Windows.Data错误:5:BindingExpression生成的值对目标属性无效。值=&#39;&#39; BindingExpression:路径=工具提示;的DataItem =&#39;按钮&#39; (名称=&#39;&#39);目标元素是&#39;按钮&#39; (名称=&#39;&#39);目标财产是&#39;姓名&#39; (键入&#39; String&#39;)

我搜索了SAP网站,但无法找到解决方案。

提前谢谢。

1 个答案:

答案 0 :(得分:1)

这是Crystal Report Viewer和WPF的已知问题。您可以添加以下代码以避免此错误:

public partial class Report_View : Window
{
    public Report_View(string param1, string reportName)
    {
        System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical;
        CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        reportDocument.Load(reportName);
        ...

您可以找到更多信息here