- This time also you have to once more Add a New Item to your project and that will be the Crystal Report which is in Reporting template, select it and click Add.


- "Crystal Report Gallery" will be there now, Select "As A Blank Report" option and click the OK button.

- You see, the report will appear in your design mode. Right click on the Database Fields node in the Field Explorer and select "Database Expert".

- Expand the "Create New Connection node".

- Again, Expand "ADO.NET (XML)" node which will display a dialog box in which we have to select the "DataSet1.xsd" file.

- Now, Click on the browse button of "File Path" and select the DataSet1.xsd file to open. And after select the file you will be able to see the full path of your file in the File Path. Then, Click on the Finish button.


- The DataTable1 node will appear now. Click on the > button to move this node to the Selected Tables list and click OK.



- The DataTable1 node will appear under the "Database Fields" node in the Field Explorer window. Expand it to see.

- Drag each field to the details section in the Crystal Report file. And Save it.

- Add the following two assemblies/ dll files to your project:
- SAPBusinessObjects.WPF.Viewer.dll
- SAPBusinessObjects.WPF.ViewerShared.dll


- Also add these highlighted lines to your code:
MainWindow.xaml:
<Window x:Class="WpfCrystalReport.MainWindow"
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="MainWindow" Height="350" Width="525">
<Grid>
<my:CrystalReportsViewer HorizontalAlignment="Left" Name="crystalReportsViewer1"
VerticalAlignment="Top" Height="500" Width="500" />
</Grid>
</Window>
- Use the following two Statements in your MainWindow.xaml.cs:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
And add the following code:
namespace WpfCrystalReport
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ReportDocument report = new ReportDocument();
report.Load("../../CrystalReport1.rpt");
using (WpfApplication4Entities1 db = new WpfApplication4Entities1())
{
report.SetDataSource(from c in db.Clients
select new { c.CustomerName, c.Address, c.EmailId, c.PassportNumber});
}
crystalReportsViewer1.ViewerCore.ReportSource = report;
}
}
}
- Lastly hit F5 to run your application and the result will be:

Happy Learning...

Riccardo DiGiacomoPosted Oct 20, 2021, 3:48 PM
I did all the necessary steps, but in "report.Load("../../CrystalReport1.rpt"); " the program have a crash, can someone tell me what could be the problem?
Alvin ChesaroPosted Oct 28, 2018, 9:00 AM
Wonderful tutorial mate. Much appreciated
Sajid AliPosted May 15, 2017, 2:24 AM
SAPBusinessObjects.WPF.Viewer.dllSAPBusinessObjects.WPF.ViewerShared.dll I need these two dlls anyone have these dlls then please send me at [email protected]
Sajid AliPosted May 15, 2017, 2:19 AM
How to download these two dll SAPBusinessObjects.WPF.Viewer.dll SAPBusinessObjects.WPF.ViewerShared.dll
Stoney RichPosted Mar 22, 2016, 4:51 PM
I tried this and I got it to work everything works well on my Developer machine but when I test it on another pc (Client) I have installed all the CR Runtimes yet the report Viewer shows but does not load the report and no error is thrown.
Mühãmmåd ßãkärPosted Jan 16, 2016, 11:39 AM
i got an exception "dataset does not support system.nullable" any Solution?
rahul nairPosted Sep 19, 2013, 4:55 AM
Thanks for your code ...But I am getting Crystal Report viewer null in xaml.cs ...But I can see the control in deisgn .I dont know why its coming in compile time
Bijay SalotryPosted Aug 23, 2013, 9:00 PM
ty...ur code help me a lot.
Gee ChaxyPosted Mar 28, 2013, 1:45 AM
Hello, could you please translate the c# code to vb.net or atleast try to comment on it,the article is very useful but the code confuses me.
Aboup LahPosted Mar 12, 2013, 1:30 PM
Hello, Thanks for this tuto. I have this error: clr-namespace:SAPBusinessObjects.WPF.Viewer; assembly=SAPBusinessObjects.WPF.Viewer' mapping URI is not valid. Please, help me.
suni sunnPosted Jan 24, 2013, 6:13 PM
Hello can you posted or upload a sample project , because i have problem in report.load("Crystalreport1.rpt"); my Email : [email protected]
praful DangrePosted Dec 11, 2012, 5:48 AM
I got This Error the tag'CrystalReportsViewer' does not exist in XML namespace 'clr-namespace:SAPBusinessObjects.WPF.Viewer; assemebly=SAPBusinessObject.WPF.Viewer'.
Shivam BhadjaPosted Nov 29, 2012, 11:54 PM
It's perfect article for beginners.......... Thanks
imran khlilPosted Aug 28, 2012, 9:35 AM
I got error, "Object reference not set to an instance of an object." when assign documentreport to reportviewer. Any Solution??
imran khlilPosted Aug 28, 2012, 9:34 AM
I got error, "Object reference not set to an instance of an object." when assign documentreport to reportviewer. Any Solution??
majid khanPosted Jul 21, 2012, 8:43 AM
using (WpfApplication4Entities1 db = new WpfApplication4Entities1()) { report.SetDataSource(from c in db.Clients select new { c.DoctorName, c.DoctorContactNo, c.DoctorAddress }); } ///////// this does not work in my visual studio specially it gives the error (WpfApplication4Entities1) plz help me [email protected]
majid khanPosted Jul 21, 2012, 8:43 AM
using (WpfApplication4Entities1 db = new WpfApplication4Entities1()) { report.SetDataSource(from c in db.Clients select new { c.DoctorName, c.DoctorContactNo, c.DoctorAddress }); } ///////// this does not work in my visual studio specially it gives the error (WpfApplication4Entities1) plz help me [email protected]
majid khanPosted Jul 21, 2012, 8:43 AM
using (WpfApplication4Entities1 db = new WpfApplication4Entities1()) { report.SetDataSource(from c in db.Clients select new { c.DoctorName, c.DoctorContactNo, c.DoctorAddress }); } ///////// this does not work in my visual studio specially it gives the error (WpfApplication4Entities1) plz help me [email protected]
BrijPosted Jun 21, 2012, 10:31 AM
I am using WPF Crystal report viewer in VS2010. How to hide Group Tree? I have tried CrystalReportViewer1.ViewCore.ToggleGroupTree=false; but thrown exception Method not found. If you know then please let me know.
selva mariappanPosted Jun 14, 2012, 2:55 PM
Hi I am new to WPF, I have a values in a data row , now i need to pass it to crystal reports in WPF , can you please help me, [email protected]
hemal asankaPosted Apr 18, 2012, 1:40 PM
This example is awesome for WPF programmers. But I have a problem about that. This print button is not working for me. Can you help me to that problem?
atanu shomePosted Jan 20, 2012, 11:13 AM
WpfApplication4Entities1 what is it? getting an error
Gary McGeehonPosted Jan 14, 2012, 12:08 AM
How would you change your code above for an existing Crystal report pointing to data in a SQL Server db? Thanks, Gary