ComContractElement::UserDefinedTypes Property

 

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

Namespace:   System.ServiceModel.Configuration
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public:
[ConfigurationPropertyAttribute("userDefinedTypes")]
property ComUdtElementCollection^ UserDefinedTypes {
	ComUdtElementCollection^ get();
}

Property Value

Type: System.ServiceModel.Configuration::ComUdtElementCollection^

The collection of User Defined Types (UDT).

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.

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

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.

.NET Framework
Available since 3.0
Return to top
Show: