If it is possible in remoting, then I am all set. But I don't think
so.. because the calls are handled by .net threadpool which are all
MTA. Once the thread has started you can not make it STA.
Also I am caching the COM objects in a global collection, because the
creation is very expensive. So when the next calls come for two
different COM objects, created by the same STA, they get queued on one
thread and the performance goes down.
I tried creating my own STA threads after receiving the call to create
object. I can do that and the object creation works fine but as soon as
the thread goes out of scope, the chached COM object in global
collection also dies and I get a "disconnected from underlying RCW"
error next time I try to access those objects.
What I need is STA threads creating the COM objects and hanging in
there for its lifetime..
[quoted text, click to view] G=FCnter Prossliner wrote:
> Hello!
>
> > All the remoting threads (from default threadpool) are MTA threads. So
> > when a request comes for MTA thread to create a COM component with
> > Apartment model, it creates an STA and creates the COM object in that
> > apartment. Subsequent calls also use the same STA if available and all
> > the objects get cached in one apartment.
>
>
> > If this description is confusing, please take a look at this brief
> > article about the same problem in ASPX pages and they have a solution.
> > I have the same problem in remoting server.
> >
> >
http://msdn.microsoft.com/msdnmag/issues/06/10/WickedCode/ >
> In ASP.Net you have no choise other than doing something like it has been
> done in this MSDN Article. Because your Application depends on the
> functionality and restrictions witch are provided by ASP.Net
>
> What the article describes as a way to let .asmx WebService run in STA
> Threads. In your Remoting Scenario you are free to use STA by default,
> aren't you?
>=20
>=20
> GP