title: Cant connect to MySQL when using Debug mode
body: <p>I have written in program in C# which connects to a MySQL database.</p>
  
  <pre><code>public bool Connect()
  {
      bool OK = true;
      try
      {
          dbcon = new MySqlConnection(ConnectionString);
      dbcon.Open();
      }
      catch 
      {
          OK = false;
      }
      return OK;
  }
  </code></pre>
  
  <p>For the connection string I am using</p>
  
  <pre><code>public string Server   = "localhost";
  public string Database = "samplemonitor";
  public string UserID   = "root";
  public string Password = "password";
  public bool Pooling    = false;
  
  
  public string ConnectionString
  {
      get 
      {
          string isPooling;
          if (Pooling)
          {
               isPooling = "true";
          }
          else
          {
              isPooling = "false";
          }
  
          return string.Format
          (
              "Server={0};Database={1};User ID={2};Password={3};Pooling={4}",
          Server,
          Database,
          UserID,
          Password,
          isPooling
          );
      }
  }
  </code></pre>
  
  <p>When I run this in debug mode in mono, the program hangs on the <strong>dbcon.Open();</strong> command</p>
  
  <p>However, when I run this program from outside the debugger, everything works fine.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Trying Vinicius' Suggestion, to use "Data Source"</p>
  
  <p>I end up with an error message</p>
  
  <blockquote>
    <p>e=11001, NativeErrorCode=11001. --->
    System.Net.Sockets.SocketException: No such host is known</p>
    
    <p>at System.Net.Dns.GetAddrInfo(String name)</p>
    
    <p>at System.Net.Dns.InternalGetHostByName(String hostName, Boolean
    includeIPv6)</p>
    
    <p>at System.Net.Dns.GetHostEntry(String hostNameOrAddress)</p>
    
    <p>at MySql.Data.Common.StreamCreator.GetDnsHostEntry(String hostname)</p>
    
    <p>--- End of inner exception stack trace ---</p>
    
    <p>at MySql.Data.Common.StreamCreator.GetDnsHostEntry(String hostname)</p>
    
    <p>at MySql.Data.Common.StreamCreator.GetHostEntry(String hostname)</p>
    
    <p>at MySql.Data.Common.StreamCreator.GetStreamFromHost(String
    pipeName, String hostName, UInt32 timeout)</p>
    
    <p>at MySql.Data.Common.StreamCreator.GetStream(UInt32 timeout)</p>
    
    <p>at MySql.Data.MySqlClient.NativeDriver.Open()</p>
    
    <p>at MySql.Data.MySqlClient.NativeDriver.Open()</p>
    
    <p>at MySql.Data.MySqlClient.Driver.Open()</p>
    
    <p>at
    MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder
    settings)</p>
    
    <p>at MySql.Data.MySqlClient.MySqlConnection.Open()</p>
    
    <p>at SampleMonitor.LocalDatabaseConnection.Connect() in
    c:\Dev\Repositories\HD-CMC\trunk\C#\SampleMonitor\SampleMonitor\Control\LocalDatabaseConnection.cs:line
    394</p>
    
    <p>MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect
    to any of the specified MySQL hosts. ---> System.Exception: Call to
    GetHostEntry failed after 00:00:00 while querying for hostname
    'samplemonitor': SocketErrorCode=HostNotFound, ErrorCode</p>
  </blockquote>
  
  <p>Its interesting that it did not hang on the open command this time</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is very strange, it just decided to start working. I haven't changed any of the code. Could this be some kind of temperamental bug in Mono??</p>