>>
>>I don't think I can give you a definitive answer to this. I've wracked my brain (something it currently doesn't take kindly to :-}) to remember where I came across this before. Essentially, I don't think it is a good idea to trigger something like this from a UI event.
>>Using Dispatcher.Invoke(), IIRC, ensures that UI processing is completed before the work begins.
>>
>>Also haven't a clue why it would work on your development machine but not on the production one. OS differences ?
>>
>>I'll sleep on this. If anything more intelligent occurs to me I come back ......
>
> Yeah, I'd look to make sure that any UI stuff is happening on the UI thread. If that's the case, then RefreshReport should be called from the form itself via the Dispatcher or BeginInvoke() (either in your "code behind" page or if you using some kind of view model, from there instead).
>
>Also, is it possible you're setting up some kind of loop between the Load event and RefreshReport call (which may cause Load to fire again, causing another RefreshReport, etc?) Just an idea. In either case I'd probably comment out the RefreshReport to see if the exception goes away, then go from there.
Hi Paul,
I commented out the
_reportViewer.RefreshReport();
line and the form at least displayed without an error (but of course without the report either.
As Viv found out I was using code from this example
http://msdn.microsoft.com/en-us/library/hh273267.aspxAs far as UI threads, dispatchers and begininvoke go, I get completely lost. I don't think I'm setting up some kind of loop (especially as it works on my PC). All I'm doing is trying to follow the MSDN example. Can you give me a suggestion of how to modify the code?
Thanks