[Mono-list] Npgsql.NpgsqlClosedState.Open An exception was thrown by the type initializer for System.Net.Dns
Andrus
kobruleht2 at hot.ee
Sun Oct 22 18:41:55 EDT 2006
npgsqlConnection1.Open() causes error
An exception was thrown by the type initializer for System.Net.Dns
Stack trace:
at Npgsql.NpgsqlClosedState.Open (Npgsql.NpgsqlConnector context) [0x00000]
at Npgsql.NpgsqlConnector.Open () [0x00000]
at Npgsql.NpgsqlConnectorPool.GetPooledConnector (Npgsql.NpgsqlConnection
Connection) [0x00000]
Stack trace from exception object is incomplete. I have no idea why.
How to fix this ?
I filed also a bug about this containing code to reproduce
http://bugzilla.ximian.com/createattachment.cgi?id=79726
Andrus.
Code which causes error:
class DataGrid : System.Windows.Forms.DataGrid
{
private Npgsql.NpgsqlConnection npgsqlConnection1;
private Npgsql.NpgsqlCommand npgsqlCommand1;
private Npgsql.NpgsqlDataAdapter npgsqlDataAdapter1;
private System.Data.DataSet dataSet1;
public DataGrid() {
InitializeComponent();
CreateLayout();
}
void CreateLayout() {
// this line causes error:
npgsqlConnection1.Open();
npgsqlCommand1.CommandText = "select * FROM myschema.mytable
order by 1";
npgsqlDataAdapter1.MissingSchemaAction =
System.Data.MissingSchemaAction.AddWithKey;
npgsqlDataAdapter1.Fill(dataSet1);
DataSource = dataSet1.Tables[0];
}
private void InitializeComponent()
{
this.npgsqlCommand1 = new Npgsql.NpgsqlCommand();
this.npgsqlConnection1 = new Npgsql.NpgsqlConnection();
this.npgsqlDataAdapter1 = new Npgsql.NpgsqlDataAdapter();
this.dataSet1 = new System.Data.DataSet();
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
this.SuspendLayout();
//
// npgsqlCommand1
//
this.npgsqlCommand1.Connection = this.npgsqlConnection1;
//
// npgsqlConnection1
//
this.npgsqlConnection1.ConnectionString =
"SERVER=localhost;DATABASE=xxxxx;USER
ID=xxxxxx;PASSWORD=xxxx;ENCODING=UNICODE;";
//
// npgsqlDataAdapter1
//
this.npgsqlDataAdapter1.DeleteCommand = null;
this.npgsqlDataAdapter1.InsertCommand = null;
this.npgsqlDataAdapter1.SelectCommand = this.npgsqlCommand1;
this.npgsqlDataAdapter1.UpdateCommand = null;
//
// dataSet1
//
this.dataSet1.DataSetName = "NewDataSet";
//
// DataGrid
//
this.CaptionBackColor =
System.Drawing.SystemColors.GradientActiveCaption;
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
this.ResumeLayout(false);
}
}
More information about the Mono-list
mailing list