PLS HELP: ActiveX control / apartment threading error

Discussion in 'ASP .Net' started by Sreejumon [MVP], Jul 8, 2003.

  1. Hi,

    If you want to use the activex controls in your asp.net
    page, you ahev to use the single aprtment thread model.
    For that please add the "aspcompat=true" attribute the
    page directive.

    Let me know the result.

    Regards
    Sreejumon
    DOTNET makes IT happen

    >-----Original Message-----
    >I am using an ActiveX control in a VB.NET user control.

    I'm using this
    >VB.NET user control inside of an ASP.NET webform. When I

    run the webform I
    >get this error:
    >Could not instantiate ActiveX control 'd940e4d2-6079-11ce-

    88cb-0020af6845f6'
    >because the current thread is not in a single-threaded

    apartment.
    >
    >In my VB.NET usercontrol I put this (after researching on

    the internet):
    ><STAThread()> Public Sub Main()
    > System.Threading.Thread.CurrentThread.ApartmentState =
    >Threading.ApartmentState.STA
    >End Sub
    >
    >Still get the same error. I know NOTHING about COM.
    >
    >Any ideas?
    >
    >Thanks,
    >Robert
    >
    >
    >.
    >
     
    Sreejumon [MVP], Jul 8, 2003
    #1
    1. Advertisements

  2. Thanks for your response.

    The good news is that I don't get that error anymore after adding that
    directive to my aspx page. The bad news is that my user control (created in
    VB.NET & contains the non-managed ActiveX control) doesn't show up on the
    page. In fact, at design time it shows up at the bottom of the webform, I
    guess because I dont have a "custom designer" or something.

    Any ideas why this control doesn't show up?

    "Sreejumon [MVP]" <> wrote in message
    news:060101c3459f$eb15d8e0$...
    > Hi,
    >
    > If you want to use the activex controls in your asp.net
    > page, you ahev to use the single aprtment thread model.
    > For that please add the "aspcompat=true" attribute the
    > page directive.
    >
    > Let me know the result.
    >
    > Regards
    > Sreejumon
    > DOTNET makes IT happen
    >
    > >-----Original Message-----
    > >I am using an ActiveX control in a VB.NET user control.

    > I'm using this
    > >VB.NET user control inside of an ASP.NET webform. When I

    > run the webform I
    > >get this error:
    > >Could not instantiate ActiveX control 'd940e4d2-6079-11ce-

    > 88cb-0020af6845f6'
    > >because the current thread is not in a single-threaded

    > apartment.
    > >
    > >In my VB.NET usercontrol I put this (after researching on

    > the internet):
    > ><STAThread()> Public Sub Main()
    > > System.Threading.Thread.CurrentThread.ApartmentState =
    > >Threading.ApartmentState.STA
    > >End Sub
    > >
    > >Still get the same error. I know NOTHING about COM.
    > >
    > >Any ideas?
    > >
    > >Thanks,
    > >Robert
    > >
    > >
    > >.
    > >
     
    VB Programmer, Jul 9, 2003
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,127
  2. vml
    Replies:
    0
    Views:
    1,275
  3. Replies:
    9
    Views:
    1,558
    Mark Space
    Dec 29, 2007
  4. Steven Woody
    Replies:
    0
    Views:
    640
    Steven Woody
    Jan 9, 2009
  5. Paul Barnett

    User control newbie question - pls help

    Paul Barnett, Oct 1, 2003, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    137
    Victor Garcia Aprea [MVP]
    Oct 23, 2003
  6. Kilic Beg
    Replies:
    0
    Views:
    248
    Kilic Beg
    Jun 8, 2004
  7. Victor

    XML Web Services and Apartment Objects

    Victor, Apr 16, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    155
    Victor
    Apr 16, 2004
  8. Andy Kasotia
    Replies:
    4
    Views:
    328
    Bob Barrows [MVP]
    Dec 9, 2005
Loading...