Hi All,
I have a .net web service try to use an ActiveX control. The code got this error"
"cannot be instantiated because the current thread is not in a single-threaded apartment"
Someone suggested for the similar error for a windows forms program that to add
[code=c]
[STAThread]
main()
{
}
[/code]
But my code is not windows form and does not have main().
I have added [STAThread] over the method but still got this error.
[code=c]
namespace MyWebService
{
[WebService(Name space = "http://tempuri.org/")]
[WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
[ToolboxItem(fal se)]
public class Service1 : System.Web.Serv ices.WebService
{
[STAThread]
[WebMethod]
public void MyMethod()
{
MyActiveControl ac = new MyActiveControl (); //causes error
}
}
}
[/code]
Thanks for the help
CS
I have a .net web service try to use an ActiveX control. The code got this error"
"cannot be instantiated because the current thread is not in a single-threaded apartment"
Someone suggested for the similar error for a windows forms program that to add
[code=c]
[STAThread]
main()
{
}
[/code]
But my code is not windows form and does not have main().
I have added [STAThread] over the method but still got this error.
[code=c]
namespace MyWebService
{
[WebService(Name space = "http://tempuri.org/")]
[WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
[ToolboxItem(fal se)]
public class Service1 : System.Web.Serv ices.WebService
{
[STAThread]
[WebMethod]
public void MyMethod()
{
MyActiveControl ac = new MyActiveControl (); //causes error
}
}
}
[/code]
Thanks for the help
CS
Comment