0

I have a lightswitch application needs to generate Crystal Report from it's WCF Ria. In the development runtime I am able to generate correctly without errors, but when I push it to release environment it prompt error - invalid cross-thread access.

I've read some articles already and it is very likely Silverlight UI Thread problem

 partial void GenerateReport_Execute()
    {
        try
        {
            GenerateCrystalReport.Load();

            var temp = DataWorkspace.QUMCrystalReportDomainData.GenerateCrystalReport(SearchQuery.SelectedItem.GroupId, sQuarter, sYear, eQuarter, eYear);

            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                var uri = new Uri("C:\\Temp\\ReportTest.pdf", UriKind.RelativeOrAbsolute);

                if (AutomationFactory.IsAvailable)
                {
                    var shell = AutomationFactory.CreateObject("Shell.Application");

                    shell.ShellExecute(uri.ToString());

                }
                else if (!System.Windows.Application.Current.IsRunningOutOfBrowser)
                {
                    HtmlPage.Window.Navigate(uri, "_blank");
                }
                else
                {
                    throw new InvalidOperationException();
                }
            });
        }
        catch ( Exception ex)
        {
            MessageBox.Show(ex.ToString());                
        }

    }

Am I doing incorrectly? please help me identify this.

Thanks in Advance

Sam

user97560
  • 1
  • 4

1 Answers1

0

Answering my question, basically that messagebox at bottom is causing the UI problem.

Lightswitch's dispatcher is not same as wpf's dispatcher(what that messagebox uses), please correct if I'm wrong

user97560
  • 1
  • 4