>>>Hi,
>>>
>>>I'm trying deploy a WPF application which uses the Windows Report Viewer. My application crashes every time I try to display the report.
>>>
>>>This is the error that shows up in the Event Viewer:
>>>
>>>"Event Type: Error
>>>Event Source: IBC Express Billing System
>>>Event Category: None
>>>Event ID: 0
>>>Date: 2/13/2013
>>>Time: 9:44:05 AM
>>>User: N/A
>>>Computer: CUSTOMS
>>>Description:
>>>Dispatcher processing has been suspended, but messages are still being processed.
>>>Source: WindowsBase
>>>Target Site: IntPtr WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
>>>Stack Trace: 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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
>>>
>>>
>>>For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp."
>>>
>>>This is my code:
>>>
>>>
>>>using System;
>>>using System.Collections.Generic;
>>>using System.Linq;
>>>using System.Text;
>>>using System.Windows;
>>>using System.Windows.Controls;
>>>using System.Windows.Data;
>>>using System.Windows.Documents;
>>>using System.Windows.Input;
>>>using System.Windows.Media;
>>>using System.Windows.Media.Imaging;
>>>using System.Windows.Shapes;
>>>using System.IO;
>>>using OakLeaf.MM.Main.WPF;
>>>
>>>namespace SamaanSystems.IBC.WPF
>>>{
>>> /// <summary>
>>> /// Interaction logic for ReportViewer.xaml
>>> /// </summary>
>>> public partial class InvoiceWithDetailReportViewer : ABusinessWindow
>>> {
>>> private string manifestNumbers;
>>>
>>> public InvoiceWithDetailReportViewer(string ManifestNumbers)
>>> {
>>> this.manifestNumbers = ManifestNumbers;
>>> InitializeComponent();
>>> _reportViewer.Load += ReportViewer_Load;
>>> }
>>>
>>> private bool _isReportViewerLoaded;
>>>
>>> private void ReportViewer_Load(object sender, EventArgs e)
>>> {
>>> if (!_isReportViewerLoaded)
>>> {
>>> if (File.Exists("./Reports/InvoiceReport.rdlc"))
>>> {
>>> Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
>>> InvoiceReportDataSet dataset = new InvoiceReportDataSet();
>>> dataset.BeginInit();
>>> reportDataSource1.Name = "DataSet1";
>>>
>>> reportDataSource1.Value = dataset.InvoicesSelectByManifestNumber;
>>> this._reportViewer.LocalReport.DataSources.Add(reportDataSource1);
>>>
>>>
>>> this._reportViewer.LocalReport.ReportPath = "./Reports/InvoiceReport.rdlc";
>>> dataset.EndInit();
>>>
>>> InvoiceReportDataSetTableAdapters.InvoicesSelectByManifestNumberTableAdapter invoiceTableAdapter = new InvoiceReportDataSetTableAdapters.InvoicesSelectByManifestNumberTableAdapter();
>>>
>>> invoiceTableAdapter.ClearBeforeFill = true;
>>> invoiceTableAdapter.Fill(dataset.InvoicesSelectByManifestNumber, this.manifestNumbers);
>>>
>>> _reportViewer.RefreshReport();
>>> _isReportViewerLoaded = true;
>>>
>>> }
>>> }
>>> }
>>> }
>>>}
>>>
>>>
>>>I have a feeling it has got something to do with the rdlc file not being found, but that's just a hunch, no scientific basis.
>>>
>>>I do have the report in a folder caled Reposrt below the folder where my exe resides, so it should be found.
>>>
>>>Can anyone help me solve this puzzle, please?
>>
>>I know nothing about Windows Report Viewer but this looks like a WPF /Dispatcher problem. How is the method called? If, as it looks, it is from a UI Event that *may* be a problem. IIRC using Dispatcher.BeginInvoke() might help - but I'm afraid that's only a vague recollection of this type of problem.....
>>
>>Update: this seems to confirm :http://social.msdn.microsoft.com/forums/en-US/wpf/thread/44962927-006e-4629-9aa3-100357861442
>
>Thanks Viv,
>
>I'd been trying to understand that post but couldn't (and still can't) grok it. Are you telling me that I need to add in that command somewhere in my code? Maybe in my ReportViewer_Load? Why would this work on my development machine as is but not at the client's site?
Ah. I see what your code was based on :-} :
http://msdn.microsoft.com/en-us/library/hh273267.aspxPresumably you have similar XAML.
So the question really is 'Why doesn't this work in production" and the most likely cause is that something *does* goes wrong in your ReportViewer_Load() method.
Couple of things I'd try:
Put some exception handling in the method which might give you more information.
For testing, try firing the method from a button after the WPF load is completed - maybe the report viewer is trying to show something before WPF is ready (but as before I know nothing of the Report Viewer behaviour).