AddOracleTypesDeserialization

This static method adds ODP.NET-specific data types to the “allow” list to permit deserialization into DataSet or DataTable.

Declaration

// C#
public static void AddOracleTypesDeserialization();

Remarks

In newer .NET versions, the allowed DataSet and DataTable data types that can be deserialized are now restricted for security reasons. This change applies to .NET 5, plus .NET Core and .NET Framework updates. If application DataSets and DataTables use Oracle data types with one of these new .NET versions, use the AddOracleTypesDeserialization method to add ODP.NET-specific data types to the “allow” list so that they can be deserialized. If an attempt is made to deserialize ODP.NET-specific types without adding them to the “allow” list, an ODP.NET type initializer exception will be encountered.

If other software that is part of the application adds data types to the allow list as well, be careful not to overwrite the ODP.NET allowed types. Be sure to only append to the allow list, not overwrite it. If overwriting does occur, call AddOracleTypesDeserialization method afterwards to add the ODP.NET types back to the list.

The ODP.NET AddOracleTypesDeserialization method call itself appends to the allow list. It does not overwrite existing entries.

This property is available in ODP.NET 19.10 and higher. It has also been backported to the latest ODP.NET 18c, 12.2, and 12.1 patches.

Example

// C#
// Sample demonstrating loading an XML file with Oracle data types into DataSet
 
using System.Data;
using Oracle.ManagedDataAccess.Client;
 
class OracleTypeDeserializationSample
{
    static void Main()
    {
      OracleConfiguration.AddOracleTypesDeserialization();
      DataSet ds = new DataSet();
      ds.ReadXml("dsch1.xml");
    }
}