Share via


Free-Threaded Components

Building Free-threaded components is not recommended; if possible, you should use the Both model instead. One disadvantage of Free-threaded components is that you must register them with the Component Services Manager in order to access the COM+ ObjectContext object, whereas all Both- or Apartment-threaded components can immediately access the COM+ ObjectContext object. This means that Free-threaded components that you have not registered with Component Services Manager can only access the ASP built-in objects through the ScriptingContext object. This method of accessing the built-in objects is considered less suitable for ASP components than using the COM+ ObjectContext object.

Another disadvantage with Free-threaded components is that, like Single-threaded components, they run in the System context, rather than in the context of the logged-on user. As a result, the Free-threaded model is not acceptable for scenarios that rely on Windows security to control access to objects.

The Microsoft Active Template Library (ATL) provides a very easy way to declare that your component supports both Apartment and Free threading models (the Both threading model). You can use the ATL Object Wizard in Visual C++ 5.0 to set the threading model support on the Attributes tab of the properties page. For more information about ATL, see the Visual Studio documentation and the Additional Resources section.