Bug 18534 - Get EngineEdition for SQL Server generate exception under Linux
Summary: Get EngineEdition for SQL Server generate exception under Linux
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-03-22 06:27 UTC by Liviu
Modified: 2014-03-23 00:19 UTC (History)
2 users (show)

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


Attachments

Description Liviu 2014-03-22 06:27:25 UTC
Hi,

Using ADO.NET and trying to get the server edition it generate an exception on Mono under Linux environment.

Example:
using (var connection = new SqlConnection(connString))
{
    connection.Open();

    foreach (var cmdText in new[] {"select serverproperty('EngineEdition')", "SELECT 1"})
    {
        using (var command = new SqlCommand(cmdText, connection))
        {
            using (var reader = command.ExecuteReader())
            {
                reader.Read();
                Console.WriteLine(reader.GetInt32(0));
            }
        }
    }
}

Exception generated:
System.IO.IOException: Read failure ---> System.Exception: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset, Int32 size, SocketFlags flags) [0x0006b] in /build/buildd/mono-3-3.2.4/mcs/class/System/System.Net.Sockets/Socket.cs:1561
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00067] in /build/buildd/mono-3-3.2.4/mcs/class/System/System.Net.Sockets/NetworkStream.cs:378
  --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00078] in /build/buildd/mono-3-3.2.4/mcs/class/System/System.Net.Sockets/NetworkStream.cs:380
  at Mono.Data.Tds.Protocol.TdsComm.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in /build/buildd/mono-3-3.2.4/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsComm.cs:611



First I noticed this behavior by using Entity Framework 6. I opened a discussion under EF Codeplex: https://entityframework.codeplex.com/discussions/538142

Because EF try to get SQL Version, at the begin of connection, this exception does not allow to be used in a Linux environment. There is a workaround for EF to avoid the issue (link above).

Anyway does not belong to EF and may be reproduced using the snippet above.

Thank you !

Liviu
Comment 1 Zoltan Varga 2014-03-23 00:19:27 UTC
-> System.Data.

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