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. Advertising

  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. Advertising

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. Alvin Bruney
    Replies:
    0
    Views:
    386
    Alvin Bruney
    Jul 9, 2003
  2. Replies:
    0
    Views:
    933
  3. vml
    Replies:
    0
    Views:
    1,098
  4. Victor

    XML Web Services and Apartment Objects

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

Share This Page