Skip to Main Content



For appeals, questions and feedback, please email

OracleBlob.Value throws exception after executing a stored procedure on Managed ODP.NET

I was put in charge of migrating our software from native ODP.NET to the managed ODP.NET, all parts of the software are now using the managed client and functioning properly so far.

The problem is in one method, we're getting a document from the database (DbType Blob) by executing a stored procedure, when I try to access the value of the output parameter (type OracleBlob) it throws this exception:

{"ORA-12571: TNS:packet writer failure"}
Oracle.ManagedDataAccess.Client.OracleException: 'ORA-12537: TNS:connection closed'

This wasn't an issue with the native The connection and command are set up correctly. There are other OracleBlob member fields that throw an exception like IsEmpty, Length, ReadTimeout.

This is my code, maybe I'm missing something:

public byte[] GetDocumentContent(long id)
    byte[] result = null;
    OracleBlob blob = null;
    OracleParameter blobImage;

    using (OracleConnection con = new OracleConnection(_conString))
        using (OracleCommand cmd = new OracleCommand("get_document_content", con))
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.Add("p_document_content_id", OracleDbType.Int64, ParameterDirection.Input).Value = id;

            blobImage = cmd.Parameters.Add("p_document_image", OracleDbType.Blob);
            blobImage.Direction = ParameterDirection.Output;


            if (((OracleBlob)blobImage.Value).IsNull == false)
                blob = (OracleBlob)blobImage.Value;
                result = blob.Value;
    return result;
This post has been answered by Alex Keh-Oracle on Jan 18 2024
Jump to Answer
Post Details
Added on Jan 17 2024