[英]CrystalReportsViewer Debug Error Message
I incorporate CrystalReportsViewer in my WPF app using VS 2015. Here is my View: 我使用VS 2015将CrystalReportsViewer合并到我的WPF应用程序中。这是我的视图:
<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>
Here is my code behind: 这是我的代码背后:
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();
}
}
The report created is correct. 创建的报告是正确的。 However, there are a lot of debug error messages.
但是,有很多调试错误消息。
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; System.Windows.Data错误:5:BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='Button' (Name='btnOpen');
DataItem ='按钮'(名称='btnOpen'); target element is 'Button' (Name='btnOpen');
目标元素是'Button'(Name ='btnOpen'); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.;
目标属性为“名称”(类型为“字符串”)System.Windows.Data错误:5:由BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='Button' (Name='btnPrint');
DataItem ='按钮'(名称='btnPrint'); target element is 'Button' (Name='btnPrint');
目标元素是“按钮”(名称=“ btnPrint”); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.;
目标属性为“名称”(类型为“字符串”)System.Windows.Data错误:5:由BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='Button' (Name='btnRefresh');
DataItem ='按钮'(名称='btnRefresh'); target element is 'Button' (Name='btnRefresh');
目标元素是“按钮”(名称=“ btnRefresh”); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.;
目标属性为“名称”(类型为“字符串”)System.Windows.Data错误:5:由BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='Button' (Name='btnExport');
DataItem ='按钮'(名称='btnExport'); target element is 'Button' (Name='btnExport');
目标元素是“按钮”(名称=“ btnExport”); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.;
目标属性为“名称”(类型为“字符串”)System.Windows.Data错误:5:由BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='Button' (Name='btnCopy');
DataItem ='按钮'(名称='btnCopy'); target element is 'Button' (Name='btnCopy');
目标元素是“按钮”(名称=“ btnCopy”); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.;
目标属性为“名称”(类型为“字符串”)System.Windows.Data错误:5:由BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='ToggleButton' (Name='btnToggleSidePanel');
DataItem ='ToggleButton'(Name ='btnToggleSidePanel'); target element is 'ToggleButton' (Name='btnToggleSidePanel');
目标元素是'ToggleButton'(Name ='btnToggleSidePanel'); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.;
目标属性为“名称”(类型为“字符串”)System.Windows.Data错误:5:由BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='Button' (Name='btnPrevPage');
DataItem ='按钮'(名称='btnPrevPage'); target element is 'Button' (Name='btnPrevPage');
目标元素是“按钮”(名称=“ btnPrevPage”); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.;
目标属性为“名称”(类型为“字符串”)System.Windows.Data错误:5:由BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='Button' (Name='btnNextPage');
DataItem ='按钮'(名称='btnNextPage'); target element is 'Button' (Name='btnNextPage');
目标元素是“按钮”(名称=“ btnNextPage”); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.;
目标属性为“名称”(类型为“字符串”)System.Windows.Data错误:5:由BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='Button' (Name='');
DataItem ='按钮'(名称=''); target element is 'Button' (Name='');
目标元素是'Button'(Name =''); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.;
目标属性为“名称”(类型为“字符串”)System.Windows.Data错误:5:由BindingExpression生成的值对于目标属性无效。 Value='' BindingExpression:Path=ToolTip;
值=''BindingExpression:Path =工具提示; DataItem='Button' (Name='');
DataItem ='按钮'(名称=''); target element is 'Button' (Name='');
目标元素是'Button'(Name =''); target property is 'Name' (type 'String')
目标属性为“名称”(类型为“字符串”)
I search SAP website and couldn't find a solution. 我搜索SAP网站,但找不到解决方案。
Thank you in advance. 先感谢您。
This is known problem with Crystal Report Viewer and WPF. 这是Crystal Report Viewer和WPF的已知问题。 You can add following code to avoid this error:
您可以添加以下代码来避免此错误:
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);
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.