Results 1 to 4 of 4

Thread: Force web service to use STAThread

  1. #1

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Force web service to use STAThread

    Is it possible to have a web service that uses the single threaded apartment model? Dropping a COM component in the designed, then running, get an error that could not instantiate the ActiveX control because the current thread is not single-threaded apartment.

    I know in a Windows Forms app, you can mark with the STAThread attribute, but there's no main method in a web service. Tried to mark the constructor with the attribute, was told I can't do that (methods only). Tried to mark the InitializeComponent method, but it didn't seem to have any effect (same error).

    Any help is appreciated.

    Thanks,
    Mike

  2. #2

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Not a solution (yet), but I did find some information. Apparently it is impossible to force the main thread of a web service to use STA. A solution suggested was to spawn a new thread that was STA. Haven't gotten around to trying it yet.

  3. #3
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Try using the AspCompat="true" page directive
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Page directive for a web service? Where would that go?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width