Bewerken

Delen via


ComContractElement.UserDefinedTypes Property

Definition

Gets a collection of User Defined Types (UDT) that is to be included in the service contract. This class cannot be inherited.

public:
 property System::ServiceModel::Configuration::ComUdtElementCollection ^ UserDefinedTypes { System::ServiceModel::Configuration::ComUdtElementCollection ^ get(); };
[System.Configuration.ConfigurationProperty("userDefinedTypes")]
public System.ServiceModel.Configuration.ComUdtElementCollection UserDefinedTypes { get; }
[<System.Configuration.ConfigurationProperty("userDefinedTypes")>]
member this.UserDefinedTypes : System.ServiceModel.Configuration.ComUdtElementCollection
Public ReadOnly Property UserDefinedTypes As ComUdtElementCollection

Property Value

The collection of User Defined Types (UDT).

Attributes

Examples

The following example demonstrates adding two specific UDTs to the <userDefinedTypes> section of the configuration file for this purpose.

<comContracts>
  <comContract contract="{5163B1E7-F0CF-4B6A-9A02-4AB654F34284}"
   namespace="http://tempuri.org/5163B1E7-F0CF-4B6A-9A02-4AB654F34284"
   name="_Broker" requiresSession="true">
    <userDefinedTypes>
      <userDefinedType name="CustomerType"
         typeLibID="{91DC728C-4F1A-45de-A9B6-B538E209CEA6}"
         typeLibVersion="1.0"
         typeDefID="{D129765C-F211-434e-825A-9A63198C41F2}" />          
      <userDefinedType name="AddressType"
         typeLibID="{91DC728C-4F1A-45de-A9B6-B538E209CEA6}"
         typeLibVersion="1.0"
         typeDefID="{4616AE0D-687A-43B7-BC63-141AE3DFD099}" />          
    </userDefinedTypes>
    <exposedMethods>
      <add exposedMethod ="BuyStock" />
      <add exposedMethod ="SellStock" />
      <add exposedMethod ="ExecuteTransaction" />
    </exposedMethods>
  </comContract>
</comContracts>

The attributes of the <userDefinedType> element are defined as follows:

  • typeName: An optional attribute that provides the readable type name. This is not used by the runtime but helps a reader to distinguish the types.

  • typeLibID: A GUID string that specifies the registered type library that defines the type.

  • typeLibVersion: A string that specifies the type library version that defines the type.

  • typeDefID: A GUID string that specifies the specific UDT type within the registered type library.

When the service is initialized, the integration runtime looks up the specified types and adds them to the known types collection for the specified contracts.

Remarks

The COM+ integration runtime creates services by inspecting the type library. When a COM+ component contains methods that pass a VARIANT, the system cannot determine the actual types to be passed prior to runtime. Therefore, when you attempt to pass a User Defined Type (UDT) within a VARIANT, it fails because it is not a known type for serialization.

To circumvent this problem, you can add the UDTs to the configuration file so that they can be included as known types on the appropriate service contract. In order to do so, you have to uniquely identify the UDT and the contract(s), that is, the original COM interface(s) that uses it.

Applies to