Bug 10164 - System.Data.OracleClient.OracleParameter.SetOracleType throws System.NullReferenceException
Summary: System.Data.OracleClient.OracleParameter.SetOracleType throws System.NullRefe...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-02-08 09:01 UTC by torbjorn.lindgren
Modified: 2013-02-08 09:01 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Attempt to fix SetOracleType (verified on our App) (687 bytes, application/octet-stream)
2013-02-08 09:01 UTC, torbjorn.lindgren
Details

Description torbjorn.lindgren 2013-02-08 09:01:07 UTC
Created attachment 3345 [details]
Attempt to fix SetOracleType (verified on our App)

I migrated an application tested and working correctly on Mono 2.6.7 (I think it's run successfully under some version of MS .NET too) to either Mono 2.10.9 or Mono 3.0.3. With both those Mono versions I get the same error when it tries to talk to the Oracle (11gR2) database, reproduced at the end.

Some searching indicates that this issue is likely identical to https://bugzilla.novell.com/show_bug.cgi?id=697933
I see that other people also have had issues with this, http://mono.1490590.n4.nabble.com/System-Data-OracleClient-OracleParameter-SetOracleType-bug-td3855825.html

To confirm I took Mono 3.0.3 and implemented the fix above and it does in fact solve this issue, the application successfully retrieves data from Oracle instead of failing with an exception. It's possible that it's a "don't do that" type of error but if so the error report probably should be made easier to understand and the old Novel bugreport not just be left ignored and "NEW".

GitHub says the failing line was added to fix https://bugzilla.novell.com/show_bug.cgi?id=667855 ~2 years ago but it doesn't seem to have been tested under all circumstances.

The Novell bugreport above mentions 2.10.x but the code in question is the same in 2.10.9, 3.0.3 and HEAD which explains why I hit it with both 2.10.9 and 3.0.3.

This is the backtrace I got originally (disappears with the attached patch to Mono):

ERROR: Database error: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Data.OracleClient.OracleParameter.SetOracleType (OracleType type, Boolean inferring) [0x00000] in <filename unknown>:0
  at System.Data.OracleClient.OracleParameter.set_OracleType (OracleType value) [0x00000] in <filename unknown>:0
  at System.Data.OracleClient.OracleParameter..ctor (System.String name, OracleType oracleType, Int32 size, ParameterDirection direction, Boolean isNullable, Byte precision, Byte scale, System.String srcColumn, DataRowVersion srcVersion, System.Object value) [0x00000] in <filename unknown>:0
  at System.Data.OracleClient.OracleParameter..ctor (System.String name, OracleType oracleType) [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Data.OracleClient.OracleParameter:.ctor (string,System.Data.OracleClient.OracleType)
  at System.Data.OracleClient.OracleParameterCollection.Add (System.String parameterName, OracleType dataType) [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Data.OracleClient.OracleParameterCollection:Add (string,System.Data.OracleClient.OracleType)
  at OurApplication.Database.OracleDBProtocol.Verify (System.String a, System.String b, System.String c) [0x00000] in <filename unknown>:0

Note You need to log in before you can comment on or make changes to this bug.