System.Net.Sockets.SocketException with MySQL Connector.NET

Hi. I already tried many things and spent already 2 days without any success. Please help or I'll hang myself.

I am using MySql.Data.dll  ver. (runtime v2.0.50727) from my project (library). It works great if i use it from WindowsApplication but once i use it same way in WebApplication, it keeps throwing:

The attempted operation is not supported for the type of object referenced

Exception Details: System.Net.Sockets.SocketException: The attempted operation is not supported for the type of object referenced

.. AsyncResult ias = socket.BeginConnect(endPoint, null, null);.. (or when called .Connection.Open)

 i use: string myConnectionString = String.Format("server={0};user id={1}; password={2}; database={3}"
                , "localhost", "aaa", "aaa", "aaa");

i set  <trust level="Full" originUrl=""/> trust in  machine.config and web.config in CONF directory of .NET framework. and in administrative tools there is  FullTrust set for all code. I tried to create custom trust level for MySql how described on web. I also tried to compile altered MySql.Data.dll.

I also get the same error if i created simple web page doing the same thing from its code

I just cannot make it to work.

4/3/2009 11:33:24 PM 1929 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 1

can you please copy the full code for connecting with the server, for the time please review the following links


proper connection please review this one

Naveed Akhtar

Microsoft Certified Professional Developer
Please remember to click “Mark as Answer”, if it is solution to your Problem
4/4/2009 8:39:48 PM
thank you  for reply!
1    <%@ Page Language="C#" Debug="true" %>
2    <%@ import Namespace="System.Data" %>
3    <%@ import Namespace="MySql.Data.MySqlClient" %>
4    <script runat="server">
6    protected void Page_Load(Object sender, EventArgs e)
7    {
8        MySqlConnection myConnection = new MySqlConnection(
9            "server=localhost; user id=actitime; password=actitime; database=actitime; pooling=false;");
11       String strSQL = "SELECT * FROM task;";
13       MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(strSQL, myConnection);
15       DataSet myDataSet = new DataSet();
16       myDataAdapter.Fill(myDataSet, "mytable");
18       MySQLDataGrid.DataSource = myDataSet;
19       MySQLDataGrid.DataBind();
20   }
22   </script>
23   <html>
24   <head>
25       <title>Simple MySQL Database Query</title>
26   </head>
27   <body>
28       <form id="Form1" runat="server">
29           <asp:DataGrid id="MySQLDataGrid" runat="server"></asp:DataGrid>
30       </form>
31   </body>
32   </html> 


The attempted operation is not supported for the type of object referenced

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: The attempted operation is not supported for the type of object referenced

Source Error:

Line 155:				new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP) :
Line 156: new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Line 157: IAsyncResult ias = socket.BeginConnect(endPoint, null, null);
Line 158: if (!ias.AsyncWaitHandle.WaitOne((int)timeOut * 1000, false))
Line 159: {


I tried other examples, same connectionString, same problem (always throws that exception when anything like myCommand.Connection.Open();):

string connectionString = String.Format("server={0};user id={1}; password={2}; database={3}"
, "localhost", "actitime", "actitime", "actitime"); //default
        MySqlCommand GetMySqlCommand(string aMySelectQuery)
            MySqlConnection myConnection = new MySqlConnection(connectionString);
            MySqlCommand myCommand = new MySqlCommand(aMySelectQuery, myConnection);

            return myCommand;


            string mySelectQuery = "select task.*, IFNULL(manHoursMinutesSum,0) as manHoursSum from\n(";
            mySelectQuery += "select, SUM(actuals/60) as manHoursMinutesSum from task ";
            mySelectQuery += "LEFT OUTER JOIN tt_record on tt_record.task_id = ";
            mySelectQuery += "where task.project_id = (select id from project where LIKE @ProjectNumber) ";
            mySelectQuery += "group by task_id";
            mySelectQuery += ") as ActualSum inner join task ON =";

            MySqlCommand myCommand = GetMySqlCommand(mySelectQuery);
            myCommand.Parameters.AddWithValue("@ProjectNumber", (aProjectNumber.ToString() + " %"));

// ...

myCommand.Connection.Open(); //THROWS EXCEPTION
MySqlDataReader myReader;
myReader = aMyCommand.ExecuteReader();

I have the same problem with both latest (5.2, 6b) MySql.Data .net connector versions. Point is: All works GREAT (same library) if used in WindowsApplication. It should be in FULL TRUST mode

4/5/2009 7:29:27 PM

 the first link helped me - i found Guided Help on Winsock2 corruption and all seems to work great. (BTW when I moved that code to the server it worked perfectly right away).

Thank you!


4/7/2009 11:43:55 PM

Similar Artilces:

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
I'm getting this error when hitting a webservice thousands of times for a mass upload. I've researched on the web and added the suggested code but am still getting the error: protected override WebRequest GetWebRequest(Uri uri) { System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)base.GetWebRequest(uri); webRequest.KeepAlive = false; return webRequest; }  Are you receiving it on the client, or on the service?John Saunders | MVP – Connected System Developer...

------_=_NextPart_001_01C6429F.D89AA417 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Net::LDAP Net::LDAPS Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, ....) password? I don't like to write the secret password to the perl file. Best regards Barbara Wilbert ------_=_NextPart_001_01C6429F.D89AA417-- Wilbert Barbara (CI/OSI) * wrote: > Hello, > > Net::LDAP > Net::LDAPS > > Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, > ......

Exception while calling .NET web service | System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
Hi,   We have written a .NET web service which retrieves an xml file from the database. This web service is SSL secured and requires client certificates for connection.   Problem: The web service is throwing an exception while retrieving large files. It works fine when the file size is around 1 MB, but fails with a file size of around 65 MB with the following exception: System.InvalidOperationException: There is an error in XML document (1, 38455668). ---> System.IO.IOException: Unable to read data from the transport connection. ---> System.Net.Sockets.SocketException: ...

Currently have a site coded in PHP but the customer wants to go to .NET. Can I use the existing MySQL DB or am I required to use MSSQL? Thanks, Ken Check out this forum which is specialized for this kind of questions: ASP.NET MySQL forumBart De Smet [MVP] Visit,

Sending SMS using or using or
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Hi, I am getting the following error. Does anyone know about this? It is working fine on some PC and giving error on others? Server Error in '/MyWebApps' Application. The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.Sockets.SocketException: The requested name is valid an...

converting to from offered me some sample code when I signed up with them the only problem is the sample code is in but my page that they type all of their credit card into is <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage(""); } private String readHtmlPage(string url) { ...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

Hi,   I am getting System.Net.Sockets.SocketException  exception on my server which is a console based application and i am using socket programming in it.i am getting this error only after 12.30am and  the server gets freezed, i am not able to trace the cause of the error as it occurs only at particular time and in particular condition, canm anyone please help me in finding the cause of this error and solution of it.Please Reply soon.   Thanks in advance Divya     These forums are for ASP.NET (web sites / web applications), not windows applica...

I've been getting this very wierd exception on the secure checkout page of a shopping cart app recently. There is no code in the page that directly uses the namespace, and the page has been pretty much error-free for a year. I guess it could be an indication that something might be wrong with IIS. Here's the stack trace: at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s...

Which mySql connector for which .NET version
Hi all,I couldn't find out which connectors target which .net versions. I have tried but could not see which are meant to target which .NET versions.Thanks for your time. guess this connector is backward compatible too, like the Oracle's.. So you may not have any issues Kumar Reddi As I understand it, you have the following: 5.2 is intended for VS 2008/.NET 3.5 5.1 is intended for VS 2005/.NET 2.0 as well as the Compact Framework 2.0 5.0 is unclear though it is appare...

net send in .net
Hi,  I am trying to execute net send comman in my code. But I am getting "win32 exception unhandled error". Please help me. My code is:Dim psi As New ProcessStartInfo() psi.UseShellExecute = False psi.FileName = "Net send" '  - IP address of a system in my network psi.Arguments = " test" Process.Start(psi)  Thanks in advance! Shwetha Tryu changing   psi.FileName = "Net send" '  - IP address of a system in my network psi.Arguments = " test&quo...

To .NET or not .NET, that is the question
I'm running WinXP pro 32-bit, meaning I've got the version 1-dot-something of .NET that XP came with. I've been looking for various softwares, and more and more often come across .NET version 2 being prerequisite. No urgency for me re. my questions to this group - so far I have just decided to hit the red X on those download pages - but the desire for this newer version of .NET seems to be growing for me. Firstly, according to my (limited) research, newer .NET versions are inclusive of the previous ones, and the current version seems to be 3.5. So if I go for i...

Net Farmers net
Has anyone been able to access any of the tests at ? I can get the default page but none of the tests appear to be operating over the last several weeks. -- CK I just tested and works as usual!!!Every session TCP_error,because my Shields_guard is intact<<G>> -- Regard: Joh@nnes� 1216771 Ont.Inc. "Nothing is more damaging to a new truth than an old error" "CK" <> wrote in message news:9i45gg$1qa9$ : Has anyone been able to access any of the tests at : http://suicide...

Web resources about - System.Net.Sockets.SocketException with MySQL Connector.NET -

Singularity RDK - Source Code
Experimental verified OS


Issues - gdata-java-client - Google Data Java Client Library - Google Project Hosting
My favorites ▼ - Sign in gdata-java-client Google Data Java Client Library Project Home Downloads Wiki Issues Source New issue Search Search ...

Some of the incredible MINECON panels didn’t make it on the livestream due to time constraints. As of right now, they have all been uploaded ...

Java™ SE Development Kit 7 Update 40 Bug Fixes
Java™ SE Development Kit 7 Update 40 Bug Fixes

Syncplicity Installation fails with error code 0x80004005 – Support Home
Symptoms : 1. The Syncplicity installation never starts. 2. The Syncplicity.log file should have the matching error code: Unregistered, Syncplicity ...

Understanding and resolving app crashes and failures in Windows Store apps, part 2: JSON and tiles
... Exception type: System.Net.WebException Message: Unable to connect to the remote server InnerException: System.Net.Sockets.SocketException, ...

The Mono-list 2003-October Archive by Subject
2003-October Archives by Subject Messages sorted by: [ thread ] [ author ] [ date ] More info on this list... Starting: Wed Oct 1 00:04:11 2003 ...

jdk6/jdk6/jdk: log
log graph tags bookmarks branches changeset browse bz2 zip gz help OpenJDK / jdk6 / jdk6 / jdk log Find changesets by keywords (author, files, ...

RSA private key import from PEM format in C#
First of all, I want to apologies for not writing. From one hand, this is not a good think for me to disappeared from development community horizons, ...

Resources last updated: 12/9/2015 10:02:02 AM