This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 35857 - [Mono 4.2] NullReferenceException in SqlDataReader.GetValues()
Summary: [Mono 4.2] NullReferenceException in SqlDataReader.GetValues()
Status: VERIFIED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: Sys.Data.SqlClient (show other bugs)
Version: 4.2.0 (C6)
Hardware: PC All
: --- normal
Target Milestone: (C6SR1)
Assignee: Marek Safar
URL:
: 36555 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-11-13 22:32 UTC by Brendan Zagaeski (Xamarin Support)
Modified: 2016-01-06 22:46 UTC (History)
7 users (show)

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


Attachments

Description Brendan Zagaeski (Xamarin Support) 2015-11-13 22:32:36 UTC
[Mono 4.2] NullReferenceException in SqlDataReader.GetValues()


This is a follow-up to Non-public Bug 30481 and Bug 29968, Comment 11.

(Note that the test case from Bug 29968, Comment 1 unfortunately does not reproduce this new problem, so the steps below use a different test case.)




## Regression status: regression in Mono 4.2 (Microsoft Reference Source import)

BAD:  Mono 4.2.1 (explicit/6dd2d0d)
GOOD: Mono 4.0.5 (detached/1d8d582)

Tested on Mac OS X 10.10.5.

(The program runs without error on .NET on Windows.)




## Steps to reproduce

Run the following program with Mono 4.2 (remove the > greater-than character from the beginning of each line). Be sure to adjust the "connectionString" to match a SQL server that you have access to.

> using System.Data.SqlClient;
> 
> class MainClass
> {
>     public static void Main (string[] args)
>     {
>         var connectionString = "Server=tcp:192.168.1.3,49189;Database=mydb;User ID=sa;Password=password123;Connection Timeout=30";
>         var dbConnection = new SqlConnection (connectionString);
>         dbConnection.Open ();
>         var schema = dbConnection.GetSchema ("Tables");
>     }
> }




## Results

### Top of the stack trace

> Unhandled Exception:
> System.NullReferenceException: Object reference not set to an instance of an object
>   at System.Data.SqlClient.SqlDataReader.GetValues (System.Object[] values) <0x2bf2b78 + 0x00051> in <filename unknown>:0 
>   at System.Data.ProviderBase.DataReaderContainer+CommonLanguageSubsetDataReader.GetValues (System.Object[] values) <0x2bf2b50 + 0x0001f> in <filename unknown>:0 
>   at System.Data.ProviderBase.SchemaMapping.LoadDataRow () <0x2bf29b8 + 0x00020> in <filename unknown>:0 
>   at System.Data.Common.DataAdapter.FillLoadDataRow (System.Data.ProviderBase.SchemaMapping mapping) <0x2bf2230 + 0x00127> in <filename unknown>:0 
>   at System.Data.Common.DataAdapter.FillFromReader (System.Data.DataSet dataset, System.Data.DataTable datatable, System.String srcTable, System.Data.ProviderBase.DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, System.Data.DataColumn parentChapterColumn, System.Object parentChapterValue) <0x2beec60 + 0x000ef> in <filename unknown>:0 
>   at System.Data.Common.DataAdapter.Fill (System.Data.DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) <0x2bee3d8 + 0x00257> in <filename unknown>:0 




## Expected result

The program runs and exits without error.
Comment 1 Brendan Zagaeski (Xamarin Support) 2015-11-13 22:42:05 UTC
## Supplemental info: steps I used to setup SQLExpress
(In case they might be helpful)


1. Install SQLExpress on a Windows machine.


2. Follow the steps on http://stackoverflow.com/a/5723880/2561894 to enable the "sa" login. For me the "LoginMode" item was located under:
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQLServer


3. Open "Sql Server Configuration Manager" ("SQLServerManager11.msc" for the version I was using).


4. Navigate to "SQL Server Network Configuration -> Protocols for SQLEXPRESS", double-click "TCP/IP", select the "IP Addresses" tab, and scroll to the bottom to find "TCP Dynamic Ports" under the "IPAll" entry. (The value was "49189" in my case.)


5. Add a firewall exception to allow inbound traffic to the port from step 4:
> C:\>netsh advfirewall firewall add rule name="SqlExpress" dir=in protocol=tcp localport=49189 profile=any remoteip=localsubnet action=allow


6. Update the "connectionString" to use the port from step 4.
Comment 5 Marek Safar 2015-11-25 13:13:28 UTC
Fixed in mono master, proposed to be included in SR1
Comment 6 Arpit Jha 2015-11-27 03:05:38 UTC
***************************
Reproduce Status
************************

I have checked this issue with latest cycle 6 mono MonoFramework-MDK-4.2.1.98.macos10.xamarin.x86_5a86dd34216d3da6a5d5f518ee72eeac001d129c and able to reproduce this issue with the help of steps mentioned in bug description.

Observation: Getting an exception mentioned in bug description.

Screencast: http://www.screencast.com/t/uxGjCbik



***************************
Verify Status
**************************

I have checked this issue with latest mono master MonoFramework-MDK-4.3.0.2203.macos10.xamarin.universal_1b6f93898e3eaaef5b4e24c63789a595d45fa8c2   and observed that its working fine, able to access schema of table .

Screencast: http://www.screencast.com/t/HAdkGv5bs135 

As per bug target milestone, I ll check and verify  this issue once the patch will merge to C6SR1 build.

Environment Info: 
=== Xamarin Studio ===

Version 5.11 (build 483)
Installation UUID: 3d25a767-a003-4a7d-9f5e-e57987cf6cf0
Runtime:
	Mono 4.3.0 (master/1b6f938)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 403002203

=== Xamarin.Profiler ===

Version: 0.23.35.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.1 (9079)
Build 7B91b

=== Xamarin.Mac ===

Not Installed

=== Xamarin.iOS ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.0.34 (Trial Edition)
Android SDK: /Users/mac360_xamarin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.1
Location: /Applications/Xamarin Android Player.app

=== Build Information ===

Release ID: 511000483
Git revision: 49935324fcab12a5922d79cbe147e24b61d5a918
Build date: 2015-11-26 05:04:28-05
Xamarin addins: 78f9f8057594fc4abe272aa828e7ed121e53e936
Build lane: monodevelop-lion-master

=== Operating System ===

Mac OS X 10.10.5
Darwin mac360-xamarins-Mac-mini.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Android Signature Tool 1.0
Addin Maker 1.2.1
NuGet Package Management Extensions 0.6
Test Template Parameters 0.2
xUnit.NET testing framework support 0.5
Manifest.addin 0.0.0.0
Comment 7 Brendan Zagaeski (Xamarin Support) 2015-12-03 22:08:42 UTC
*** Bug 36555 has been marked as a duplicate of this bug. ***
Comment 8 Brendan Zagaeski (Xamarin Support) 2015-12-08 23:58:02 UTC
## Status update for any users CC'd on the bug

The candidate fix for this issue is not yet included in the preliminary Alpha version of "Cycle 6 – Service Release 1" published today, but that is mostly because those builds are still just early Alpha versions. The candidate fix will likely be included in a future preview version of "Cycle 6 – Service Release 1."
Comment 9 Arpit Jha 2015-12-17 11:59:11 UTC
I have checked this issue with latest C6SR1 build and its working fine.

Observation: We are not getting any exception.

Screencast: http://www.screencast.com/t/W36VeAUcR

Hence closing this issue.

Environment Info:

=== Xamarin Studio ===

Version 5.10.2 (build 45)
Installation UUID: 3d25a767-a003-4a7d-9f5e-e57987cf6cf0
Runtime:
	Mono 4.2.2 (explicit/d35418c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402020018

=== Xamarin.Profiler ===

Version: 0.23.35.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: 9.4.1.8 (Enterprise Edition)
Hash: f146d47
Branch: master
Build date: 2015-12-15 16:23:04-0500

=== Xamarin.Android ===

Version: 6.0.1.5 (Enterprise Edition)
Android SDK: /Users/mac360_xamarin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.1
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.4.0.109 (Enterprise Edition)

=== Build Information ===

Release ID: 510020045
Git revision: 08c06a8631ef84137ba5cec2721bed98d28ead2a
Build date: 2015-12-15 18:32:20-05
Xamarin addins: aac4d51e07ccd5b3bc172d8cd42245c7066feb99
Build lane: monodevelop-lion-cycle6-c6sr1

=== Operating System ===

Mac OS X 10.10.5
Darwin mac360-xamarins-Mac-mini.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 10 Matthew Blott 2016-01-06 22:46:38 UTC
Hi, the packages on the website need to be updated. There is no option for 4.2.2.

Thanks :-)

http://origin-download.mono-project.com/repo/debian/dists/wheezy/snapshots/4.2/snapshots/

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