Be Thread-Aware in ASP.NET
Thread awareness is not an issue specific to managed code, but you should know about it anyway. ASP.NET uses a multithreaded apartment (MTA) thread pool. (All managed code components use MTA.) When you call a COM object marked as using a single-threaded apartment (STA), the Web application switches threads and loses the impersonation context. The way around this is by using AspCompatMode=true to run a page on an STA thread. This is the only supported scenario for using STA components from ASP.NET. You can also call CoImpersonateClient in your component if you rely on the behavior.
That said, you should not use STA components anyway they can be a huge performance drag on ASP.NET.
Visual Basic 6 COM components use STA. | |