Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
tools
vsnet.act
vsnet.debugging
vsnet.documentation
vsnet.enterprise.tools
vsnet.general
vsnet.ide
vsnet.jlca
vsnet.servicepacks
vsnet.setup
vsnet.vsip
vsnet.vss
vsnet.vstools.office
vstudio.development
vstudio.extensibility
vstudio.general
vstudio.helpauthoring
vstudio.setup
vstudio.sourcesafe
  
 
date: Tue, 1 Jul 2008 13:07:31 -0700 (PDT),    group: microsoft.public.vsnet.general        back       


ConfigurationManager.ConnectionStrings drivin' me crazy   
My solution has 2 projects: and winform app and a class library. In
the class library project I have an app.config file with the following
xml (VS2005):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <connectionStrings>
    <add name="BKT_IMG_ConnectionString"
        connectionString="Data Source=VALMIRC1;Initial
Catalog=BKT_IMG;Integrated Security=True"
        providerName="System.Data.SqlClient" />
  </connectionStrings>

  <appSettings>
    <add key="DBConnStr" value="Integrated Security=SSPI;Persist
Security Info=False;User  ID=bktadmin;Password=Imagem;Initial
Catalog=BKT_IMG;Data Source=10.50.7.62" />
  </appSettings>
</configuration>

My class is tryiong to read the connectionStrings section with the
following code:

using System.Configuration;
using gDB = GlobalDataBase.GlobalDB;

namespace MDIRules
{
    public class Checks
    {
        public Checks()
        {
            gDB.ConnectionString =
ConfigurationManager.ConnectionStrings["BKT_IMG_ConnectionString"].ToString();
        }
    }
}

and I'm facing a system.nullreferenceException : Object reference no
set to an instance of an object. Why? Why? I've included
System.Configuration reference to my project as I saw on other posts
and still cannot read this section.

Any help will be apreciated

Thanks
date: Tue, 1 Jul 2008 13:07:31 -0700 (PDT)   author:   VC

Re: ConfigurationManager.ConnectionStrings drivin' me crazy   
Sorry. I got it. the section cant be in the app.config class project.
It must be in the application app.config file. Sad but True...


On 1 jul, 17:07, VC  wrote:
> My solution has 2 projects: and winform app and a class library. In
> the class library project I have an app.config file with the following
> xml (VS2005):
>
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>
>   <connectionStrings>
>     <add name="BKT_IMG_ConnectionString"
>         connectionString="Data Source=VALMIRC1;Initial
> Catalog=BKT_IMG;Integrated Security=True"
>         providerName="System.Data.SqlClient" />
>   </connectionStrings>
>
>   <appSettings>
>     <add key="DBConnStr" value="Integrated Security=SSPI;Persist
> Security Info=False;User  ID=bktadmin;Password=Imagem;Initial
> Catalog=BKT_IMG;Data Source=10.50.7.62" />
>   </appSettings>
> </configuration>
>
> My class is tryiong to read the connectionStrings section with the
> following code:
>
> using System.Configuration;
> using gDB = GlobalDataBase.GlobalDB;
>
> namespace MDIRules
> {
>     public class Checks
>     {
>         public Checks()
>         {
>             gDB.ConnectionString =
> ConfigurationManager.ConnectionStrings["BKT_IMG_ConnectionString"].ToString();
>         }
>     }
>
> }
>
> and I'm facing a system.nullreferenceException : Object reference no
> set to an instance of an object. Why? Why? I've included
> System.Configuration reference to my project as I saw on other posts
> and still cannot read this section.
>
> Any help will be apreciated
>
> Thanks
date: Tue, 1 Jul 2008 13:15:00 -0700 (PDT)   author:   VC

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us