unknow error after SHOW function was called.

Stimulsoft Reports.NET discussion
Post Reply
Codmasters
Posts: 2
Joined: Tue Oct 20, 2020 1:04 am

unknow error after SHOW function was called.

Post by Codmasters »

i have code running perfectly but the when i call SHOW function on stimulsoft my program is crashing and if just change SHOW function to PRINT the app just give me this error "an error occurred during this operation"

Code: Select all

var sr_ReportBuilder = new StiReport();
                sr_ReportBuilder.Load("Reports\\Report23.mrt");
                sr_ReportBuilder.Show();
------------------------------------------------------
System.InvalidOperationException
HResult=0x80131509
Message=DragDrop registration did not succeed.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
at System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

This exception was originally thrown at this call stack:
[External Code]

Inner Exception 1:
ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.
---------------------------------------------------------------
farzan
Posts: 2
Joined: Tue Oct 20, 2020 7:13 pm

Re: unknow error after SHOW function was called.

Post by farzan »

Please run your code like below and see if it helps:

WFP:

Code: Select all

Application.Current.Dispatcher.Invoke(
    () =>
    {
         var sr_ReportBuilder = new StiReport();
         sr_ReportBuilder.Load("Reports\\Report23.mrt");
         sr_ReportBuilder.Show();
    });
WinForm:

Code: Select all

public partial class Form1: Form
{
    private readonly SynchronizationContext uiContext;

    public Form1()
    {
        InitializeComponent();
        uiContext = SynchronizationContext.Current; // get UI context
    }

    private void yourFunc()
    {
            uiContext.Send((object state) =>
            {
                 var sr_ReportBuilder = new StiReport();
                 sr_ReportBuilder.Load("Reports\\Report23.mrt");
                 sr_ReportBuilder.Show();
            }, null);
    }
}
Codmasters
Posts: 2
Joined: Tue Oct 20, 2020 1:04 am

Re: unknow error after SHOW function was called.

Post by Codmasters »

farzan wrote: Tue Oct 20, 2020 9:08 pm Please run your code like below and see if it helps:

WFP:

Code: Select all

Application.Current.Dispatcher.Invoke(
    () =>
    {
         var sr_ReportBuilder = new StiReport();
         sr_ReportBuilder.Load("Reports\\Report23.mrt");
         sr_ReportBuilder.Show();
    });
WinForm:

Code: Select all

public partial class Form1: Form
{
    private readonly SynchronizationContext uiContext;

    public Form1()
    {
        InitializeComponent();
        uiContext = SynchronizationContext.Current; // get UI context
    }

    private void yourFunc()
    {
            uiContext.Send((object state) =>
            {
                 var sr_ReportBuilder = new StiReport();
                 sr_ReportBuilder.Load("Reports\\Report23.mrt");
                 sr_ReportBuilder.Show();
            }, null);
    }
}
still same error!!
Lech Kulikowski
Posts: 6265
Joined: Tue Mar 20, 2018 5:34 am

Re: unknow error after SHOW function was called.

Post by Lech Kulikowski »

Hello,

Please send us a sample project that reproduces the issue for analysis.

Also, please check :
https://social.msdn.microsoft.com/Forum ... ?forum=clr

Thank you.
Post Reply