Hi all,
The following code shows a from with a report viewer on a new thread. It works fine with VSTO 2008 but fails on 2010, with a InvalidOperationException claiming:
"Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on."
This Does not happen for form with no controls of with other controls (i.e. TextBox)
namespace CrystalReportsApplication2_2008
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form f = new Form();
f.Controls.Add(new TextBox());
f.Controls.Add(new CrystalDecisions.Windows.Forms.CrystalReportViewer());
Thread t = new Thread(ShowForm);
t.Start(f);
Application.Run();
}
private static void ShowForm(object data)
{
Form f = ((Form)data);
f.Show();
Application.Run();
}
}
}
We are moving to 2010 and are now paralized by this problem (the whole development team is out of work for three days now). We need help.
Best,
Asher