General .NET Programming Recommendations and Tips for ODP.NET

  • Thread.Abort() should not be used, as unmanaged resources may remain unreleased, which can potentially cause memory leaks and hangs.

  • To optimize resource usage, ODP.NET objects, such as OracleConnection and OracleCommand, should be explicitly closed or disposed, or both, when they are no longer needed. This should be done rather than relying on the .NET Framework garbage collector to reclaim resources. Many users have found that under stress conditions, explicit Close or Dispose calls result in much lower resource usage.

  • It is recommended not to proceed with application execution if the application encounters exceptions that are associated with possible memory corruption, such as System.AccessViolationException and System.Runtime.InteropServices.SEHException.

  • If the HKEY_LOCAL_MACHINE\Software\Oracle\NLS_LANG registry entry is set to NA, ODP.NET encounters ORA-12705 errors. To eliminate this problem, remove the HKEY_LOCAL_MACHINE\Software\Oracle\NLS_LANG registry entry.

  • .NET requires certain special characters, such as backslash \ and double quotation mark ", to be escaped when used within a string. In a connection string or a class property, .NET requires using the escape character, backslash, before the special character. To represent a backslash in a string, use a double backslash \\. To represent a double quotation mark in a string, use a backslash followed by a double quotation mark \". Alternatively, use the at sign @ to mark the entire string as a verbatim string literal, in which case .NET ignores special characters.