This is a migrated thread and some comments may be shown as answers.

ReportProcessor - Render Xps

1 Answer 105 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael Bendtsen
Top achievements
Rank 1
Michael Bendtsen asked on 26 Feb 2010, 10:31 AM
Hi

I have created my own WCF service which uses the ReportProcessor to render an Xps to be used in the WPF DocumentViewer control. It worked fine when using the ReportProcessor directly from the App. But at soon as I move it to a service it fails.

I have created unit test that proves that the ReportProcessor works fine.

I get the following exception:
Test method Dako.ReportingService.UnitTest.DakoReportServiceTest.TestRenderXpsWithServiceHost threw exception:  System.ServiceModel.FaultException: FixedDocument must contain at least one FixedPage..

And when I look at the Debug trace I see another error:
----------------------------------------------------------------------------------------------------------------------------------
...

*** Measure Report (Vertical) STARTED ***
*** Measure Report (Vertical) DONE in 00:00:00.0008545 ***

*** Measure Report (Vertical) STARTED ***
*** Measure Report (Vertical) DONE in 00:00:00.0010941 ***

*** Measure Report (Vertical) DONE in 00:00:00.0055121 ***

*** ProcessReport #0 DONE in 00:00:00.3215597 ***

*** RenderReport #0 STARTED ***

*** RENDER PAGES STARTED ***
*** RENDER PAGES DONE in 00:00:00.0028726 ***

An error has occured while rendering the report: System.InvalidOperationException: The calling thread must be STA, because many UI components require this.
   at System.Windows.Input.InputManager..ctor()
   at System.Windows.Input.InputManager.GetCurrentInputManagerImpl()
   at System.Windows.Input.InputManager.get_Current()
   at System.Windows.Input.KeyboardNavigation..ctor()
   at System.Windows.FrameworkElement.FrameworkServices..ctor()
   at System.Windows.FrameworkElement.EnsureFrameworkServices()
   at System.Windows.FrameworkElement..ctor()
   at System.Windows.Controls.Panel..ctor()
   at System.Windows.Controls.Canvas..ctor()
   at Telerik.Reporting.XamlRendering.CompositionXamlBase.NewPhysicalPage()
   at Telerik.Reporting.XamlRendering.CompositionXps.NewPhysicalPage()
   at Telerik.Reporting.ImageRendering.CompositionBase.NextUsableArea()
   at Telerik.Reporting.ImageRendering.CompositionBase.NextHorizontalPage()
   at Telerik.Reporting.ImageRendering.ImageRendererBase.ProcessPages(CompositionBase composition, RenderingElement renderingReport, Int32 startPage, Int32 endPage, Boolean render)
   at Telerik.Reporting.ImageRendering.ImageRendererBase.ProcessPages(Report report, CompositionBase composition, Int32 startPage, Int32 endPage, Boolean render)
   at Telerik.Reporting.ImageRendering.ImageRendererBase.RenderReport(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback)
*** RenderReport #0 DONE in 00:00:00.0068132 ***

*** ReportProcessor.Render DONE in 00:00:00.3291403 ***

---------------------------------------------------------------------------------------------------------------------------------

I have another test that also calls the service which passes.

What am I doint wrong?

Best regards,
Michael

1 Answer, 1 is accepted

Sort by
0
Michael Bendtsen
Top achievements
Rank 1
answered on 01 Mar 2010, 08:52 AM
Found a solution. Create a new thread, set the apartment state to STA.
Tags
General Discussions
Asked by
Michael Bendtsen
Top achievements
Rank 1
Answers by
Michael Bendtsen
Top achievements
Rank 1
Share this question
or