Wednesday, March 21, 2012

Please Help Me for single-threaded apartment

I meet this err, Please help me how to do! (ASP.NET)
Thanks all

"Could not instantiate ActiveX control '46faf861-9911-4d2d-8370-e96e96029bc4' because the current thread is not in a single-threaded apartment. "

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Threading.ThreadStateException: Could not instantiate ActiveX control '46faf861-9911-4d2d-8370-e96e96029bc4' because the current thread is not in a single-threaded apartment.

Source Error:

Line 7: <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Line 8:
Line 9: xserver = New AxiMeetNowServer2Lib.AxiMeetNowServer2
Line 10: Me.xserver.Name = "server"
Line 11: Me.xserver.OcxState = CType(GetObject("server.OcxState"), System.Windows.Forms.AxHost.State)

Source File: c:\inetpub\wwwroot\VC\WebForm1.aspx.vb Line: 9

Stack Trace:

[ThreadStateException: Could not instantiate ActiveX control '46faf861-9911-4d2d-8370-e96e96029bc4' because the current thread is not in a single-threaded apartment.]
System.Windows.Forms.AxHost..ctor(String clsid, Int32 flags)
System.Windows.Forms.AxHost..ctor(String clsid)
AxiMeetNowServer2Lib.AxiMeetNowServer2..ctor()
VC.WebForm1.InitializeComponent() in c:\inetpub\wwwroot\VC\WebForm1.aspx.vb:9
VC.WebForm1.Page_Init(Object sender, EventArgs e) in c:\inetpub\wwwroot\VC\WebForm1.aspx.vb:30
System.Web.UI.Control.OnInit(EventArgs e)
System.Web.UI.Control.InitRecursive(Control namingContainer)
System.Web.UI.Page.ProcessRequestMain()

------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573this usually occurs when trying to convert an ASP page to ASP.NET, but you could try this:

in the <@.Page> directive in the HMTL add this:

<%@.Page aspcompat="true" ... %
this adds a compatibitity directive to your page that should allow STA model to function properly.

0 comments:

Post a Comment