To
specify the
COM+ application’s activation type, you can use the
ApplicationActivation
assembly attributes. You can request
that the application be a library or a server application:
[assembly: ApplicationActivation(ActivationOption.Server)]
or:
[assembly: ApplicationActivation(ActivationOption.Library)]
If you do not provide the ApplicationActivation
attribute, then .NET uses a library activation type by default. Note
that this use differs from the COM+ default of creating a new
application as a server application.
The next release of Windows 2000, Windows XP (see Appendix B), allows a COM+ application to be activated as
a system service, so I expect that
ApplicationActivation
will be extended to include
the value of ActivationOption.Service
.
Before I describe other serviced components attributes, you need to
understand what attributes are. Every .NET attribute
is actually a class, and the attribute class has a constructor (maybe
even a few overloaded constructors) and, usually, a few properties
you can set. The syntax for declaring an attribute is different from
that of any other class. In C#, you specify the attribute type
between square brackets [...]
. You specify
constructor parameters and the values of the properties you wish to
set between parentheses (...)
.
In the case of the ApplicationActivation
attribute, there are no properties and the constructor must accept an
enum parameter of type
ActivationOption
, defined as:
enum ActivationOption{Server,Library}
There is no default constructor for the
ApplicationActivation
attribute.
The ApplicationActivation
attribute is defined in
the
System.EnterpriseServices
namespace. Your must add this namespace
to your project references and reference that namespace in your
assembly information file:
using System.EnterpriseServices;
The rest of this chapter assumes that you have added these references and will not mention them again.