StrataFrame Forum

StrataFrame with Report Sharp-Shooter

http://forum.strataframe.net/Topic16568.aspx

By Rogerio Mauri - 5/24/2008

If you received the error below when choosing an option of the menu of previewForm

Crying-------------------------------------------------
ThreadStateException
O thread atual deve ser definido no modo STA (single thread apartment) antes que chamadas OLE possam ser feitas. Verifique se a função Main tem STAThreadAttribute marcado. A exceção somente será gerada se um depurador estiver anexado ao processo.

Source : System.Windows.Forms
-------------------------------------------------


It sees the code below to solve the problem:

Wink
#region CodeArea(StrataFrame with Report Sharp-Shooter) in new Thread(STA)

private void inlineReportSlot2_RenderCompleted(object sender, EventArgs e)
{
    Thread newThread = new Thread(new ThreadStart(Exibe));
    newThread.SetApartmentState(ApartmentState.STA);
    newThread.Start();
}

void Exibe()
{
    Thread.Sleep(0);
    using (PerpetuumSoft.Reporting.View.PreviewForm previewForm = new PerpetuumSoft.Reporting.View.PreviewForm(inlineReportSlot2))
    {
        previewForm.WindowState = FormWindowState.Maximized;
        previewForm.ShowDialog();
    }
}

#endregion