Delen via


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.

See Also

Concepts

Data Access from CLR Database Objects

Other Resources

CREATE ASSEMBLY (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance