Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

XML Serialization from CLR Database Objects

XML serialization is required for two scenarios:

  • Invoking Web Services from common language runtime (CLR) objects.

  • Converting a user-defined type (UDT) to XML.

Performing XML serialization by invoking the XmlSerializer class normally generates an additional serialization assembly that is overloaded into the project with the source assembly. However, for security purposes, this overload is disabled in the CLR. Therefore, to call a web service or perform conversion from UDT to XML inside SQL Server, the assembly must be created manually using a tool called Sgen.exe provided with the .NET Framework that generates the necessary serialization assemblies. When invoking XmlSerializer, the serialization assembly must be created manually by following these steps:

  1. Run the Sgen.exe tool that is provided with the .NET Framework SDK to create the assembly containing the XML serializers for the source assembly.

  2. Register the generated assembly in SQL Server using the CREATE ASSEMBLY statement.

For information about errors that you may receive when performing XML serialization, see the following Microsoft Support article: "Cannot load dynamically generated serialization assembly".

For information on data types that are not supported by XMLSerializer, see XML Schema Binding Support in the .NET Framework in the .NET Framework documentation.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.