Bug 60133 - Mono.Data.Tds - Cannot access a disposed object. Object name: 'System.Net.Sockets.NetworkStream'.
Summary: Mono.Data.Tds - Cannot access a disposed object. Object name: 'System.Net.Soc...
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2017-10-11 15:27 UTC by Claudio Rodrigo Pereyra Diaz
Modified: 2018-02-22 22:37 UTC (History)
2 users (show)

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

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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Claudio Rodrigo Pereyra Diaz 2017-10-11 15:27:44 UTC
Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00014] in /builddir/build/BUILD/mono-4.4.2/external/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:488 
  at Mono.Data.Tds.Protocol.TdsComm.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in /builddir/build/BUILD/mono-4.4.2/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsComm.cs:657 

I use https://github.com/hamekoz/hamekoz-sharp/blob/master/Hamekoz.Data/DB.cs by nuget https://www.nuget.org/packages/Hamekoz.Data/

An example code:

using System;
using System.Data;
using Hamekoz.Data;

namespace MyNameSpace
	class MainClass
		public static void Main (string[] args)
                       DB.Instancia.ConnectionString = "Data Source=server;Initial Catalog=catalog user id=user;Password=password;"
                       var dataset = DB.Instancia.SPToDataSet ("SPName");
                       Console.WriteLine("Tables count {0}", dataset.Tables.Count);

I confirm the bug with mono 4.4.2 and 4.2.x from Fedora 25 and Fedora 24 official packages.
I use SQL Server for data. The SPName is a long time query for one table with many many records as result. 

Actual result:
All most call to SP crash with Cannot access a disposed object.

Result expected:
dataset populate with result of SPName call.

# mono -V
Mono JIT compiler version 4.4.2 (Stable Tue Aug  2 08:14:37 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
Comment 1 Marek Safar 2017-10-13 11:43:36 UTC
Thank you for your report!

It appears you are running a very old version of Mono. Could you please try to update to any recent version and try to reproduce the issue again.

If the issue still persists please include the version information and change the bug status to NEW.
Comment 2 Marek Safar 2018-02-22 22:37:24 UTC
Mono 5.10 has significantly improved System.Data implementation which should resolve this issue. If you can still reproduce it please reopen the issue.