469,903 Members | 1,463 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

An unhandled exception of type 'System.NullReferenceException' occurred in my_deepot_common.dll

i have this class library that connects to the database(see appconfig below)

compiling 0 errors but when its running i amhaving this error

An unhandled exception of type 'System.NullReferenceException' occurred in
my_deepot_common.dll Object reference not set to an instance of an obj

int this line

public System.Data.SqlClient.SqlConnection user_connection = new
System.Data.SqlClient.SqlConnection(System.Configu ration.ConfigurationManager.ConnectionStrings["my_deepot_common.Properties.Settings.utilizadores ConnectionString"].ConnectionString);

thanks

using System;

using System.Collections.Generic;

using System.Text;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

namespace my_deepot_common

{

public class DB_Connection

{
public System.Data.SqlClient.SqlConnection user_connection = new
System.Data.SqlClient.SqlConnection(System.Configu ration.ConfigurationManager.ConnectionStrings["my_deepot_common.Properties.Settings.utilizadores ConnectionString"].ConnectionString);

public System.Data.SqlClient.SqlConnection lang_connection = new
System.Data.SqlClient.SqlConnection(System.Configu ration.ConfigurationManager.ConnectionStrings["my_deepot_common.Properties.Settings.linguagemCon nectionString"].ConnectionString);

public DB_Connection()

{
}


}

}

APP_CONFIG

<connectionStrings>
<add
name="my_deepot_common.Properties.Settings.linguag emConnectionString"
connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=E:\my_deepot\ my_deepot_common\Data\linguagem.mdf;Integrated
Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
<add
name="my_deepot_common.Properties.Settings.utiliza doresConnectionString"
connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=E:\my_deepot\ my_deepot_common\Data\utilizadores.mdf;Integrated
Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

Dec 21 '07 #1
1 2985
the connection string was malformed

public System.Data.SqlClient.SqlConnection user_connection = new
System.Data.SqlClient.SqlConnection("Data
Source=.\\SQLEXPRESS;AttachDbFilename=E:\\my_deepo t\\comum\\Data\\utilizadores.mdf;Integrated
Security=True;User Instance=True");
public System.Data.SqlClient.SqlConnection lang_connection = new
System.Data.SqlClient.SqlConnection("Data
Source=.\\SQLEXPRESS;AttachDbFilename=E:\\my_deepo t\\comum\\Data\\linguagem.mdf;Integrated
Security=True;User Instance=True");

//public System.Data.SqlClient.SqlConnection user_connection = new
System.Data.SqlClient.SqlConnection(System.Configu ration.ConfigurationManager.ConnectionStrings["comum.Properties.Settings.utilizadoresConnectionS tring"].ConnectionString);
//public System.Data.SqlClient.SqlConnection lang_connection = new
System.Data.SqlClient.SqlConnection(System.Configu ration.ConfigurationManager.ConnectionStrings["comum.Properties.Settings.linguagemConnectionStri ng"].ConnectionString);
"Pedro Dinis" <pe***@code4cerveja.comescreveu na mensagem
news:D1**********************************@microsof t.com...
>i have this class library that connects to the database(see appconfig
below)

compiling 0 errors but when its running i amhaving this error

An unhandled exception of type 'System.NullReferenceException' occurred in
my_deepot_common.dll Object reference not set to an instance of an obj

int this line

public System.Data.SqlClient.SqlConnection user_connection = new
System.Data.SqlClient.SqlConnection(System.Configu ration.ConfigurationManager.ConnectionStrings["my_deepot_common.Properties.Settings.utilizadores ConnectionString"].ConnectionString);

thanks

using System;

using System.Collections.Generic;

using System.Text;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

namespace my_deepot_common

{

public class DB_Connection

{
public System.Data.SqlClient.SqlConnection user_connection = new
System.Data.SqlClient.SqlConnection(System.Configu ration.ConfigurationManager.ConnectionStrings["my_deepot_common.Properties.Settings.utilizadores ConnectionString"].ConnectionString);

public System.Data.SqlClient.SqlConnection lang_connection = new
System.Data.SqlClient.SqlConnection(System.Configu ration.ConfigurationManager.ConnectionStrings["my_deepot_common.Properties.Settings.linguagemCon nectionString"].ConnectionString);

public DB_Connection()

{
}


}

}

APP_CONFIG

<connectionStrings>
<add
name="my_deepot_common.Properties.Settings.linguag emConnectionString"
connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=E:\my_deepot\ my_deepot_common\Data\linguagem.mdf;Integrated
Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
<add
name="my_deepot_common.Properties.Settings.utiliza doresConnectionString"
connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=E:\my_deepot\ my_deepot_common\Data\utilizadores.mdf;Integrated
Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Dec 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Professor Frink | last post: by
7 posts views Thread by Chuck Hartman | last post: by
1 post views Thread by mike | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.