Export (0) Print
Expand All

ComUdtElement Class

Represents a User Defined Type (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 sealed class ComUdtElement : ConfigurationElement

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.

</services>
<!-- <comContracts> is under <system.ServiceModel> and at the same level-->
<!-- as <services> or <behaviors> -->
<comContracts>
  <comContract contract="{5163B1E7-F0CF-4B6A-9A02-4AB654F34284}"
    name="_Broker" namespace="http://tempuri.org/5163B1E7-F0CF-4B6A-9A02-4AB654F34284"
    requiresSession="true">
    <exposedMethods>
      <add exposedMethod="BuyStock" />
      <add exposedMethod="SellStock" />
      <add exposedMethod="ExecuteTransaction" />
    </exposedMethods>
    <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>
  </comContract>
</comContracts>

<behaviors>

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 COM+ integration runtime looks up the specified types and adds them to the known types collection for the specified contracts.

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

</services>
<!-- <comContracts> is under <system.ServiceModel> and at the same level-->
<!-- as <services> or <behaviors> -->
<comContracts>
  <comContract contract="{5163B1E7-F0CF-4B6A-9A02-4AB654F34284}"
    name="_Broker" namespace="http://tempuri.org/5163B1E7-F0CF-4B6A-9A02-4AB654F34284"
    requiresSession="true">
    <exposedMethods>
      <add exposedMethod="BuyStock" />
      <add exposedMethod="SellStock" />
      <add exposedMethod="ExecuteTransaction" />
    </exposedMethods>
    <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>
  </comContract>
</comContracts>

<behaviors>

System.Object
  System.Configuration.ConfigurationElement
    System.ServiceModel.Configuration.ComUdtElement

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

ADD
Show:
© 2014 Microsoft