這個主題提供 System.EnterpriseServices 命名空間中每一個設計階段屬性的預設值。知道每一個屬性的預設值之後,您可以排除程式碼中不必要的屬性。如果您對中繼資料 (Metadata) 上的屬性角色不熟悉,請參閱使用屬性 (Attribute) 擴充中繼資料。
下列是每一個與服務相關的屬性之預設使用資訊:
屬性範圍 - 辨識屬性是否只適用於方法、類別,或適用於整個組件。
未設定的預設值 - 顯示當程式碼省略屬性時 COM+ 指派給欄位的值。例如,如果省略類別的 JustInTimeActivationAttribute 屬性,COM+ 會將預設值設定為 False。
設定的預設值 - 顯示當您套用屬性但省略屬性值時 COM+ 指派給欄位的值。下列範例會說明如何將類別上的 JustInTimeActivationAttribute 屬性設定為 True:
Imports System.EnterpriseServices <JustInTimeActivation()> Public Class Account Inherits ServicedComponent Shared Sub Main() End Sub End Class [C#] using System.EnterpriseServices; [JustInTimeActivation] public class Account : ServicedComponent { static void Main() {} }Makefile.bat
您可以依照下列方式編譯範例:
vbc /t:exe /r:System.EnterpriseServices.dll Demo.vb [C#] csc /t:exe /r:System.EnterpriseServices.dll Demo.cs
與服務相關的屬性
下列表格會列出與服務相關的屬性範圍 (Scope),以及設定和未設定的預設值。
| 屬性 | 屬性範圍 | 未設定的預設值 | 設定的預設值 |
|---|---|---|---|
| ApplicationAccessControlAttribute | Assembly | True | True |
| ApplicationActivationAttribute | Assembly | Library | 無預設值 |
| ApplicationIDAttribute | Assembly | 產生的 GUID | 無預設值 |
| ApplicationNameAttribute | Assembly | 組件名稱 | 無預設值 |
| ApplicationQueuingAttribute | Assembly | 無預設值 | 無預設值 |
| AutoCompleteAttribute | Method | False | True |
| ComponentAccessControlAttribute | Class | False | True |
| COMTIIntrinsicsAttribute | Class | False | True |
| ConstructionEnabledAttribute | Class | False | True |
| DescriptionAttribute | Assembly
Class Method Interface |
無預設值 | 無預設值 |
| EventClassAttribute | Class | 無預設值 | FireInParallel = False
AllowInprocSubsribers = True PublisherFilter = Null |
| EventTrackingEnabledAttribute | Class | False | True |
| ExceptionClassAttribute | Class | 無預設值 | 無預設值 |
| IISIntrinsicsAttribute | Class | False | True |
| InterfaceQueuingAttribute | Class
Interface |
False | True |
| JustInTimeActivationAttribute | Class | False | True |
| LoadBalancingSupportedAttribute | Class | False | True |
| MustRunInClientContextAttribute | Class | False | True |
| ObjectPoolingAttribute | Class | False | True |
| PrivateComponentAttribute | Class | 無預設值 | Private |
| SecureMethodAttribute | Assembly
Class Method |
無預設值 | 無預設值 |
| SecurityRoleAttribute | Assembly
Class Interface |
無預設值 | 無預設值 |
| SynchronizationAttribute | Class | False | SynchronizationOption.Required |
| TransactionAttribute | Class | False | TransactionOption.Required
TransactionIsolationLevel.Serializable Timeout = infinite |
請參閱
撰寫服務元件 | System.EnterpriseServices | 服務元件概觀 | 註冊服務元件 | 服務元件範例 | 可用的 COM+ 服務摘要 | 使用屬性 (Attribute) 擴充中繼資料 | System.EnterpriseServices 命名空間