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 ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-02-08 09:01 UTC by torbjorn.lindgren
Modified: 2013-02-08 09:01 UTC (History)
1 user (show)

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

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 10164 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

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