J
JP2006
Getting a an error with my DLL stating that my control 'cannot be
instantiated because the current thread is not in a single-threaded
apartment.'
The code is:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace xCapture
{
public class xcap
{
static void Main()
{
Thread newThread = new Thread(new ThreadStart(createXCap));
newThread.SetApartmentState(ApartmentState.STA);
}
public static void createXCap()
{
WebBrowser wb = new WebBrowser();
wb.Visible = false;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It fails on the line - WebBrowser wb = new WebBrowser();
Have tried setting [STAThread] on the main method also to no avail.
Any ideas?
instantiated because the current thread is not in a single-threaded
apartment.'
The code is:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace xCapture
{
public class xcap
{
static void Main()
{
Thread newThread = new Thread(new ThreadStart(createXCap));
newThread.SetApartmentState(ApartmentState.STA);
}
public static void createXCap()
{
WebBrowser wb = new WebBrowser();
wb.Visible = false;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It fails on the line - WebBrowser wb = new WebBrowser();
Have tried setting [STAThread] on the main method also to no avail.
Any ideas?