Problem calling Report Designer from Win32 program
Posted: Tue Nov 09, 2010 10:40 am
Hi!
I am using the COM wrapper around the StimulSoft classes to design & print the reports. Since COM registration has become an issue at my customer's site, I was looking for alternatives and came across a site which could help convert a Managed DLL into a Unmanaged DLL (http://www.codeproject.com/KB/dotnet/Dl ... play=Print). To use this required me to changed all the methods in the wrapper to public static methods. I am currently able to Print my reports (without COM) using this DLL but I have a problem with Designing the report i.e. whenever the report.Design() method is called, I get the following error which involves the Microsoft Web Browse ActiveX object. What is the solution for this? Any help will be appreciated.
Wrapper method ::
public static void StiDesignReport()
{
report.Design();
}
ERROR ::
************** Exception Text **************
System.Threading.ThreadStateException: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
at System.Windows.Forms.WebBrowserBase..ctor(String clsidString)
at System.Windows.Forms.WebBrowser..ctor()
at Stimulsoft.Report.Design.Controls.StiDesignerHtmlPreviewControl..ctor(StiDesignerControl designer)
at Stimulsoft.Report.Design.StiBuilder.AddHtmlPreviewTab()
at Stimulsoft.Report.Design.StiBuilder.BuildReport()
at Stimulsoft.Report.Design.StiDesignerControl.Refresh()
at Stimulsoft.Report.Design.StiDesignerControl.SetZoom(Single zoom)
at Stimulsoft.Report.Design.StiDesignerControl.SetZoom(Double zoom)
at Stimulsoft.Report.Design.StiDesignerConfigService.Load()
at Stimulsoft.Report.Design.StiDesignerControl.LoadDesignerParam()
at Stimulsoft.Report.Design.StiDesignerControl.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4952 (win7RTMGDR.050727-4900)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
StiReport
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/fg/qc/dll/StiReport.DLL
----------------------------------------
Stimulsoft.Report
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Report.DLL
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
Stimulsoft.Base
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Base.DLL
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
Stimulsoft.Report.Design
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Report.Design.DLL
----------------------------------------
Stimulsoft.Report.Helper
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Report.Helper.DLL
----------------------------------------
Stimulsoft.Controls.Win
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Controls.Win.DLL
----------------------------------------
Stimulsoft.Report.Win
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Report.Win.DLL
----------------------------------------
Stimulsoft.Editor
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Editor.DLL
----------------------------------------
Accessibility
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
Stimulsoft.Controls
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Controls.DLL
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
Regards
I am using the COM wrapper around the StimulSoft classes to design & print the reports. Since COM registration has become an issue at my customer's site, I was looking for alternatives and came across a site which could help convert a Managed DLL into a Unmanaged DLL (http://www.codeproject.com/KB/dotnet/Dl ... play=Print). To use this required me to changed all the methods in the wrapper to public static methods. I am currently able to Print my reports (without COM) using this DLL but I have a problem with Designing the report i.e. whenever the report.Design() method is called, I get the following error which involves the Microsoft Web Browse ActiveX object. What is the solution for this? Any help will be appreciated.
Wrapper method ::
public static void StiDesignReport()
{
report.Design();
}
ERROR ::
************** Exception Text **************
System.Threading.ThreadStateException: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
at System.Windows.Forms.WebBrowserBase..ctor(String clsidString)
at System.Windows.Forms.WebBrowser..ctor()
at Stimulsoft.Report.Design.Controls.StiDesignerHtmlPreviewControl..ctor(StiDesignerControl designer)
at Stimulsoft.Report.Design.StiBuilder.AddHtmlPreviewTab()
at Stimulsoft.Report.Design.StiBuilder.BuildReport()
at Stimulsoft.Report.Design.StiDesignerControl.Refresh()
at Stimulsoft.Report.Design.StiDesignerControl.SetZoom(Single zoom)
at Stimulsoft.Report.Design.StiDesignerControl.SetZoom(Double zoom)
at Stimulsoft.Report.Design.StiDesignerConfigService.Load()
at Stimulsoft.Report.Design.StiDesignerControl.LoadDesignerParam()
at Stimulsoft.Report.Design.StiDesignerControl.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4952 (win7RTMGDR.050727-4900)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
StiReport
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/fg/qc/dll/StiReport.DLL
----------------------------------------
Stimulsoft.Report
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Report.DLL
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
Stimulsoft.Base
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Base.DLL
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
Stimulsoft.Report.Design
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Report.Design.DLL
----------------------------------------
Stimulsoft.Report.Helper
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Report.Helper.DLL
----------------------------------------
Stimulsoft.Controls.Win
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Controls.Win.DLL
----------------------------------------
Stimulsoft.Report.Win
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Report.Win.DLL
----------------------------------------
Stimulsoft.Editor
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Editor.DLL
----------------------------------------
Accessibility
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
Stimulsoft.Controls
Assembly Version: 2010.2.743.0
Win32 Version: 2010.2.743.0
CodeBase: file:///D:/fg/qc/dll/Stimulsoft.Controls.DLL
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
Regards