468,786 Members | 1,755 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Passing the connection string from a web form to a business logic component

Hi all..

I have created a business logic component that is used from my ASP.NET
webform. It works, but connection string to the database is hard coded, as
in this method :

public DataSet GetCategories()
{
SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
Catalog=XXXX;User ID=X;Password=Y");
SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM FROM
CATEGORIA ORDER BY CAT_NOM", conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}

I need to know what is the best way to pass the connection string that is
present in the web.config file. I tried using a constructor in that business
class but with no success. Also I have read that ObjectDataSource uses
stateless components so I think the usage of properties isn't allowed here.

The question is, the only solution I could implement is passing the
connection string as a parameter to GetCategories? is there another one?
Since this method resides in a DLL, I cannot use ConnectionManager class to
access web.config file.

Thanks a lot
Jaime
Nov 19 '05 #1
19 2179
if you have it in Web.Config like:-
<add key="ConnectionString" value="server=(local);database=YourDB;integrated
security=true;" />
Then in you app do:-
myconnection = New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Is that what you are looking for.
Patrick
"Jaime Stuardo" <js******@manquehue.net> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
Hi all..

I have created a business logic component that is used from my ASP.NET
webform. It works, but connection string to the database is hard coded, as
in this method :

public DataSet GetCategories()
{
SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
Catalog=XXXX;User ID=X;Password=Y");
SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM FROM CATEGORIA ORDER BY CAT_NOM", conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}

I need to know what is the best way to pass the connection string that is
present in the web.config file. I tried using a constructor in that business class but with no success. Also I have read that ObjectDataSource uses
stateless components so I think the usage of properties isn't allowed here.
The question is, the only solution I could implement is passing the
connection string as a parameter to GetCategories? is there another one?
Since this method resides in a DLL, I cannot use ConnectionManager class to access web.config file.

Thanks a lot
Jaime

Nov 19 '05 #2
the best solution is to write you own application setting class (use
interfaces). this allows multiple implementation of loading settings, but
one for reading.

hint: use the factory model to allow a static create method.

-- bruce (sqlwork.com)

"Jaime Stuardo" <js******@manquehue.net> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
Hi all..

I have created a business logic component that is used from my ASP.NET
webform. It works, but connection string to the database is hard coded, as
in this method :

public DataSet GetCategories()
{
SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
Catalog=XXXX;User ID=X;Password=Y");
SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM
FROM CATEGORIA ORDER BY CAT_NOM", conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}

I need to know what is the best way to pass the connection string that is
present in the web.config file. I tried using a constructor in that
business class but with no success. Also I have read that ObjectDataSource
uses stateless components so I think the usage of properties isn't allowed
here.

The question is, the only solution I could implement is passing the
connection string as a parameter to GetCategories? is there another one?
Since this method resides in a DLL, I cannot use ConnectionManager class
to access web.config file.

Thanks a lot
Jaime

Nov 19 '05 #3
Hi Patrick..

I cannot do that since this method is in a DLL that is referenced by the
ASP.NET project. When I use AppSettings from the component, I receive a
null. However I think I could use what you suggested if I have public
DataSet GetCategories(String connectionStr).

By the way, I use ASP.NET 2.0 and in this version
ConfigurationSettings.AppSettings is reported as obsolete. I should use
ConfigurationManager.AppSettings instead.

Jaime

"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:em**************@TK2MSFTNGP12.phx.gbl...
if you have it in Web.Config like:-
<add key="ConnectionString"
value="server=(local);database=YourDB;integrated
security=true;" />
Then in you app do:-
myconnection = New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Is that what you are looking for.
Patrick
"Jaime Stuardo" <js******@manquehue.net> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
Hi all..

I have created a business logic component that is used from my ASP.NET
webform. It works, but connection string to the database is hard coded,
as
in this method :

public DataSet GetCategories()
{
SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
Catalog=XXXX;User ID=X;Password=Y");
SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM

FROM
CATEGORIA ORDER BY CAT_NOM", conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}

I need to know what is the best way to pass the connection string that is
present in the web.config file. I tried using a constructor in that

business
class but with no success. Also I have read that ObjectDataSource uses
stateless components so I think the usage of properties isn't allowed

here.

The question is, the only solution I could implement is passing the
connection string as a parameter to GetCategories? is there another one?
Since this method resides in a DLL, I cannot use ConnectionManager class

to
access web.config file.

Thanks a lot
Jaime


Nov 19 '05 #4
FYI, to actually use System.Configuration.ConfigurationManager.AppSetti ngs
in 2.0 you must add a reference to System.configuration.dll. (I wasted a
lot of time trying to figure that out).

This is not necessary to do to use
System.Configuration.ConfigurationSettings.AppSett ings and I not sure why.
Can anyone explain?

Greg

"Jaime Stuardo" <js******@manquehue.net> wrote in message
news:uM*************@TK2MSFTNGP14.phx.gbl...
Hi Patrick..

I cannot do that since this method is in a DLL that is referenced by the
ASP.NET project. When I use AppSettings from the component, I receive a
null. However I think I could use what you suggested if I have public
DataSet GetCategories(String connectionStr).

By the way, I use ASP.NET 2.0 and in this version
ConfigurationSettings.AppSettings is reported as obsolete. I should use
ConfigurationManager.AppSettings instead.

Jaime

"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:em**************@TK2MSFTNGP12.phx.gbl...
if you have it in Web.Config like:-
<add key="ConnectionString"
value="server=(local);database=YourDB;integrated
security=true;" />
Then in you app do:-
myconnection = New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Is that what you are looking for.
Patrick
"Jaime Stuardo" <js******@manquehue.net> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
Hi all..

I have created a business logic component that is used from my ASP.NET
webform. It works, but connection string to the database is hard coded,
as
in this method :

public DataSet GetCategories()
{
SqlConnection conn = new SqlConnection("Data
Source=DEVSERVER;Initial
Catalog=XXXX;User ID=X;Password=Y");
SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM

FROM
CATEGORIA ORDER BY CAT_NOM", conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}

I need to know what is the best way to pass the connection string that
is
present in the web.config file. I tried using a constructor in that

business
class but with no success. Also I have read that ObjectDataSource uses
stateless components so I think the usage of properties isn't allowed

here.

The question is, the only solution I could implement is passing the
connection string as a parameter to GetCategories? is there another one?
Since this method resides in a DLL, I cannot use ConnectionManager class

to
access web.config file.

Thanks a lot
Jaime



Nov 19 '05 #5
Hi, Greg.

re:
Can anyone explain?
System.Configuration.ConfigurationSettings.AppSett ings
is a class in the System.Configuration namespace in system.dll.

System.Configuration.ConfigurationManager.AppSetti ngs isn't.

See :

http://www.asp.net/QUICKSTART/util/c....Configuration

Configuration.ConfigurationManager is a class which resides in
System.Configuration (in system.configuration.dll), not in system.dll
which is where Configuration.ConfigurationSettings.AppSettings resides.

It's a bit confusing because the System.Configuration first names seem the same,
but -just like you do with people- you need a first name *and* a last name
to identify individuals.

The System.Configuration class in System.dll is really System.System.Configuration
( notice the *two* "system" in the name ) but we don't have to identify the base
namespace because it's automatically imported in all aspx pages.

If you want to use the ConfigurationManager.AppSettings class which is
a part of system.configuration.dll without importing the namespace,
you'll need to use its full name :

System.Configuration.System.Configuration.Configur ationManager.AppSettings

That because the System.Configuration.System.Configuration namespace
is *not* imported automatically into every aspx page.

I hope this is clearer to you now.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:ut*************@TK2MSFTNGP15.phx.gbl... FYI, to actually use System.Configuration.ConfigurationManager.AppSetti ngs in 2.0 you
must add a reference to System.configuration.dll. (I wasted a lot of time trying to
figure that out).

This is not necessary to do to use
System.Configuration.ConfigurationSettings.AppSett ings and I not sure why. Can anyone
explain?

Greg

"Jaime Stuardo" <js******@manquehue.net> wrote in message
news:uM*************@TK2MSFTNGP14.phx.gbl...
Hi Patrick..

I cannot do that since this method is in a DLL that is referenced by the ASP.NET
project. When I use AppSettings from the component, I receive a null. However I think I
could use what you suggested if I have public DataSet GetCategories(String
connectionStr).

By the way, I use ASP.NET 2.0 and in this version ConfigurationSettings.AppSettings is
reported as obsolete. I should use ConfigurationManager.AppSettings instead.

Jaime

"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:em**************@TK2MSFTNGP12.phx.gbl...
if you have it in Web.Config like:-
<add key="ConnectionString" value="server=(local);database=YourDB;integrated
security=true;" />
Then in you app do:-
myconnection = New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Is that what you are looking for.
Patrick
"Jaime Stuardo" <js******@manquehue.net> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
Hi all..

I have created a business logic component that is used from my ASP.NET
webform. It works, but connection string to the database is hard coded, as
in this method :

public DataSet GetCategories()
{
SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
Catalog=XXXX;User ID=X;Password=Y");
SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM
FROM
CATEGORIA ORDER BY CAT_NOM", conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}

I need to know what is the best way to pass the connection string that is
present in the web.config file. I tried using a constructor in that
business
class but with no success. Also I have read that ObjectDataSource uses
stateless components so I think the usage of properties isn't allowed
here.

The question is, the only solution I could implement is passing the
connection string as a parameter to GetCategories? is there another one?
Since this method resides in a DLL, I cannot use ConnectionManager class
to
access web.config file.

Thanks a lot
Jaime



Nov 19 '05 #6
'System' does not exist in the namespace 'System.Configuration'

I added C:\Windows\Microsoft.NET\Framework\v2.0.50727\Syst em.configuration.dll
I also added using System.Configuration;

Here is the line of code it errors on.
string sConnString =
System.Configuration.System.Configuration.Configur ationManager.AppSettings["dsn"];
For now, I'm staying with ConfigurationSettings and live with the warnings.
string sConnString =
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];
"Juan T. Llibre" wrote:
Hi, Greg.

re:
Can anyone explain?


System.Configuration.ConfigurationSettings.AppSett ings
is a class in the System.Configuration namespace in system.dll.

System.Configuration.ConfigurationManager.AppSetti ngs isn't.

See :

http://www.asp.net/QUICKSTART/util/c....Configuration

Configuration.ConfigurationManager is a class which resides in
System.Configuration (in system.configuration.dll), not in system.dll
which is where Configuration.ConfigurationSettings.AppSettings resides.

It's a bit confusing because the System.Configuration first names seem the same,
but -just like you do with people- you need a first name *and* a last name
to identify individuals.

The System.Configuration class in System.dll is really System.System.Configuration
( notice the *two* "system" in the name ) but we don't have to identify the base
namespace because it's automatically imported in all aspx pages.

If you want to use the ConfigurationManager.AppSettings class which is
a part of system.configuration.dll without importing the namespace,
you'll need to use its full name :

System.Configuration.System.Configuration.Configur ationManager.AppSettings

That because the System.Configuration.System.Configuration namespace
is *not* imported automatically into every aspx page.

I hope this is clearer to you now.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:ut*************@TK2MSFTNGP15.phx.gbl...
FYI, to actually use System.Configuration.ConfigurationManager.AppSetti ngs in 2.0 you
must add a reference to System.configuration.dll. (I wasted a lot of time trying to
figure that out).

This is not necessary to do to use
System.Configuration.ConfigurationSettings.AppSett ings and I not sure why. Can anyone
explain?

Greg

"Jaime Stuardo" <js******@manquehue.net> wrote in message
news:uM*************@TK2MSFTNGP14.phx.gbl...
Hi Patrick..

I cannot do that since this method is in a DLL that is referenced by the ASP.NET
project. When I use AppSettings from the component, I receive a null. However I think I
could use what you suggested if I have public DataSet GetCategories(String
connectionStr).

By the way, I use ASP.NET 2.0 and in this version ConfigurationSettings.AppSettings is
reported as obsolete. I should use ConfigurationManager.AppSettings instead.

Jaime

"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:em**************@TK2MSFTNGP12.phx.gbl...
if you have it in Web.Config like:-
<add key="ConnectionString" value="server=(local);database=YourDB;integrated
security=true;" />
Then in you app do:-
myconnection = New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Is that what you are looking for.
Patrick
"Jaime Stuardo" <js******@manquehue.net> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
> Hi all..
>
> I have created a business logic component that is used from my ASP.NET
> webform. It works, but connection string to the database is hard coded, as
> in this method :
>
> public DataSet GetCategories()
> {
> SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
> Catalog=XXXX;User ID=X;Password=Y");
> SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM
FROM
> CATEGORIA ORDER BY CAT_NOM", conn);
> DataSet ds = new DataSet();
> adapter.Fill(ds);
> return ds;
> }
>
> I need to know what is the best way to pass the connection string that is
> present in the web.config file. I tried using a constructor in that
business
> class but with no success. Also I have read that ObjectDataSource uses
> stateless components so I think the usage of properties isn't allowed
here.
>
> The question is, the only solution I could implement is passing the
> connection string as a parameter to GetCategories? is there another one?
> Since this method resides in a DLL, I cannot use ConnectionManager class
to
> access web.config file.
>
> Thanks a lot
> Jaime
>
>



Nov 19 '05 #7
Just import system.configuration and use :
string sConnString = System.Configuration.ConfigurationManager.AppSetti ngs["dsn"];

The thing is that the ConfigurationManager class isn't meant to be used
just to read a key and insert the key's string value into a connection.

It's meant to be used to *modify* configuration files.

If you just want to read a value in web.config, use :
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Mike L" <Ca***@nospam.nospam> wrote in message
news:F1**********************************@microsof t.com...
'System' does not exist in the namespace 'System.Configuration'

I added C:\Windows\Microsoft.NET\Framework\v2.0.50727\Syst em.configuration.dll
I also added using System.Configuration;

Here is the line of code it errors on.
string sConnString =
System.Configuration.System.Configuration.Configur ationManager.AppSettings["dsn"];
For now, I'm staying with ConfigurationSettings and live with the warnings.
string sConnString =
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];
"Juan T. Llibre" wrote:
Hi, Greg.

re:
> Can anyone explain?


System.Configuration.ConfigurationSettings.AppSett ings
is a class in the System.Configuration namespace in system.dll.

System.Configuration.ConfigurationManager.AppSetti ngs isn't.

See :

http://www.asp.net/QUICKSTART/util/c....Configuration

Configuration.ConfigurationManager is a class which resides in
System.Configuration (in system.configuration.dll), not in system.dll
which is where Configuration.ConfigurationSettings.AppSettings resides.

It's a bit confusing because the System.Configuration first names seem the same,
but -just like you do with people- you need a first name *and* a last name
to identify individuals.

The System.Configuration class in System.dll is really System.System.Configuration
( notice the *two* "system" in the name ) but we don't have to identify the base
namespace because it's automatically imported in all aspx pages.

If you want to use the ConfigurationManager.AppSettings class which is
a part of system.configuration.dll without importing the namespace,
you'll need to use its full name :

System.Configuration.System.Configuration.Configur ationManager.AppSettings

That because the System.Configuration.System.Configuration namespace
is *not* imported automatically into every aspx page.

I hope this is clearer to you now.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:ut*************@TK2MSFTNGP15.phx.gbl...
> FYI, to actually use System.Configuration.ConfigurationManager.AppSetti ngs in 2.0 you
> must add a reference to System.configuration.dll. (I wasted a lot of time trying to
> figure that out).
>
> This is not necessary to do to use
> System.Configuration.ConfigurationSettings.AppSett ings and I not sure why. Can anyone
> explain?
>
> Greg
>
> "Jaime Stuardo" <js******@manquehue.net> wrote in message
> news:uM*************@TK2MSFTNGP14.phx.gbl...
>> Hi Patrick..
>>
>> I cannot do that since this method is in a DLL that is referenced by the ASP.NET
>> project. When I use AppSettings from the component, I receive a null. However I
>> think I
>> could use what you suggested if I have public DataSet GetCategories(String
>> connectionStr).
>>
>> By the way, I use ASP.NET 2.0 and in this version ConfigurationSettings.AppSettings
>> is
>> reported as obsolete. I should use ConfigurationManager.AppSettings instead.
>>
>> Jaime
>>
>> "Patrick.O.Ige" <na********@hotmail.com> wrote in message
>> news:em**************@TK2MSFTNGP12.phx.gbl...
>>> if you have it in Web.Config like:-
>>> <add key="ConnectionString" value="server=(local);database=YourDB;integrated
>>> security=true;" />
>>> Then in you app do:-
>>> myconnection = New
>>> SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
>>> Is that what you are looking for.
>>> Patrick
>>>
>>>
>>> "Jaime Stuardo" <js******@manquehue.net> wrote in message
>>> news:ef**************@TK2MSFTNGP14.phx.gbl...
>>>> Hi all..
>>>>
>>>> I have created a business logic component that is used from my ASP.NET
>>>> webform. It works, but connection string to the database is hard coded, as
>>>> in this method :
>>>>
>>>> public DataSet GetCategories()
>>>> {
>>>> SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
>>>> Catalog=XXXX;User ID=X;Password=Y");
>>>> SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM
>>> FROM
>>>> CATEGORIA ORDER BY CAT_NOM", conn);
>>>> DataSet ds = new DataSet();
>>>> adapter.Fill(ds);
>>>> return ds;
>>>> }
>>>>
>>>> I need to know what is the best way to pass the connection string that is
>>>> present in the web.config file. I tried using a constructor in that
>>> business
>>>> class but with no success. Also I have read that ObjectDataSource uses
>>>> stateless components so I think the usage of properties isn't allowed
>>> here.
>>>>
>>>> The question is, the only solution I could implement is passing the
>>>> connection string as a parameter to GetCategories? is there another one?
>>>> Since this method resides in a DLL, I cannot use ConnectionManager class
>>> to
>>>> access web.config file.
>>>>
>>>> Thanks a lot
>>>> Jaime
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Nov 19 '05 #8
> If you want to use the ConfigurationManager.AppSettings class which is
a part of system.configuration.dll without importing the namespace,
you'll need to use its full name :

System.Configuration.System.Configuration.Configur ationManager.AppSettings

That because the System.Configuration.System.Configuration namespace
is *not* imported automatically into every aspx page.

I hope this is clearer to you now.
Not really. I guess I'm a little dense. :^)

This, of course, compiles just fine:
Dim sConnString As String =
System.Configuration.ConfigurationManager.AppSetti ngs("dsn")

and this (because System is imported by default in VB)
Dim sConnString As String =
Configuration.ConfigurationManager.AppSettings("ds n")

and if I import System.Configuation I would just use:
Imports System.Configuration
Dim sConnString As String = ConfigurationManager.AppSettings("dsn")

but now this won't compile: ?
Imports System.Configuration
Dim sConnString As String =
Configuration.ConfigurationManager.AppSettings("ds n")
Error: 'System' is not a member of 'System.Configuration.Configuration'

And I can't get this line to compile at all...?
Dim sConnString As String =
System.Configuration.System.Configuration.Configur ationManager.AppSettings("dsn")

Error: 'System' is not a member of 'Configuration'

I don't think I will ever completely understand this. Don't bother trying to
explain it to me again, I'm hopeless. :^)
The thing is that the ConfigurationManager class isn't meant to be used
just to read a key and insert the key's string value into a connection.

It's meant to be used to *modify* configuration files.

If you just want to read a value in web.config, use :
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];


Interesting, never heard that metioned before. I thought we were expected
to stop using System.Configuration.ConfigurationSettings.AppSett ings?

Greg

Nov 19 '05 #9
I'm reading a value from App.config
My project is a C# 2005 win form application.

Should I ignore the warring messages for "string sConnString =
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];" ?

"Juan T. Llibre" wrote:
Just import system.configuration and use :
string sConnString = System.Configuration.ConfigurationManager.AppSetti ngs["dsn"];

The thing is that the ConfigurationManager class isn't meant to be used
just to read a key and insert the key's string value into a connection.

It's meant to be used to *modify* configuration files.

If you just want to read a value in web.config, use :
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Mike L" <Ca***@nospam.nospam> wrote in message
news:F1**********************************@microsof t.com...
'System' does not exist in the namespace 'System.Configuration'

I added C:\Windows\Microsoft.NET\Framework\v2.0.50727\Syst em.configuration.dll
I also added using System.Configuration;

Here is the line of code it errors on.
string sConnString =
System.Configuration.System.Configuration.Configur ationManager.AppSettings["dsn"];
For now, I'm staying with ConfigurationSettings and live with the warnings.
string sConnString =
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];
"Juan T. Llibre" wrote:
Hi, Greg.

re:
> Can anyone explain?

System.Configuration.ConfigurationSettings.AppSett ings
is a class in the System.Configuration namespace in system.dll.

System.Configuration.ConfigurationManager.AppSetti ngs isn't.

See :

http://www.asp.net/QUICKSTART/util/c....Configuration

Configuration.ConfigurationManager is a class which resides in
System.Configuration (in system.configuration.dll), not in system.dll
which is where Configuration.ConfigurationSettings.AppSettings resides.

It's a bit confusing because the System.Configuration first names seem the same,
but -just like you do with people- you need a first name *and* a last name
to identify individuals.

The System.Configuration class in System.dll is really System.System.Configuration
( notice the *two* "system" in the name ) but we don't have to identify the base
namespace because it's automatically imported in all aspx pages.

If you want to use the ConfigurationManager.AppSettings class which is
a part of system.configuration.dll without importing the namespace,
you'll need to use its full name :

System.Configuration.System.Configuration.Configur ationManager.AppSettings

That because the System.Configuration.System.Configuration namespace
is *not* imported automatically into every aspx page.

I hope this is clearer to you now.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:ut*************@TK2MSFTNGP15.phx.gbl...
> FYI, to actually use System.Configuration.ConfigurationManager.AppSetti ngs in 2.0 you
> must add a reference to System.configuration.dll. (I wasted a lot of time trying to
> figure that out).
>
> This is not necessary to do to use
> System.Configuration.ConfigurationSettings.AppSett ings and I not sure why. Can anyone
> explain?
>
> Greg
>
> "Jaime Stuardo" <js******@manquehue.net> wrote in message
> news:uM*************@TK2MSFTNGP14.phx.gbl...
>> Hi Patrick..
>>
>> I cannot do that since this method is in a DLL that is referenced by the ASP.NET
>> project. When I use AppSettings from the component, I receive a null. However I
>> think I
>> could use what you suggested if I have public DataSet GetCategories(String
>> connectionStr).
>>
>> By the way, I use ASP.NET 2.0 and in this version ConfigurationSettings.AppSettings
>> is
>> reported as obsolete. I should use ConfigurationManager.AppSettings instead.
>>
>> Jaime
>>
>> "Patrick.O.Ige" <na********@hotmail.com> wrote in message
>> news:em**************@TK2MSFTNGP12.phx.gbl...
>>> if you have it in Web.Config like:-
>>> <add key="ConnectionString" value="server=(local);database=YourDB;integrated
>>> security=true;" />
>>> Then in you app do:-
>>> myconnection = New
>>> SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
>>> Is that what you are looking for.
>>> Patrick
>>>
>>>
>>> "Jaime Stuardo" <js******@manquehue.net> wrote in message
>>> news:ef**************@TK2MSFTNGP14.phx.gbl...
>>>> Hi all..
>>>>
>>>> I have created a business logic component that is used from my ASP.NET
>>>> webform. It works, but connection string to the database is hard coded, as
>>>> in this method :
>>>>
>>>> public DataSet GetCategories()
>>>> {
>>>> SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
>>>> Catalog=XXXX;User ID=X;Password=Y");
>>>> SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM
>>> FROM
>>>> CATEGORIA ORDER BY CAT_NOM", conn);
>>>> DataSet ds = new DataSet();
>>>> adapter.Fill(ds);
>>>> return ds;
>>>> }
>>>>
>>>> I need to know what is the best way to pass the connection string that is
>>>> present in the web.config file. I tried using a constructor in that
>>> business
>>>> class but with no success. Also I have read that ObjectDataSource uses
>>>> stateless components so I think the usage of properties isn't allowed
>>> here.
>>>>
>>>> The question is, the only solution I could implement is passing the
>>>> connection string as a parameter to GetCategories? is there another one?
>>>> Since this method resides in a DLL, I cannot use ConnectionManager class
>>> to
>>>> access web.config file.
>>>>
>>>> Thanks a lot
>>>> Jaime
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Nov 19 '05 #10
Well, other than an obvious typo, it's a sound explanation.

If you need to verify, download Lutz Roeder's Reflector:
http://www.aisto.com/roeder/dotnet/
and take a look at both assemblies : System.dll and System.configuration.dll

You'll understand what I meant immediately.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:eW**************@TK2MSFTNGP09.phx.gbl...
If you want to use the ConfigurationManager.AppSettings class which is
a part of system.configuration.dll without importing the namespace,
you'll need to use its full name :

System.Configuration.System.Configuration.Configur ationManager.AppSettings

That because the System.Configuration.System.Configuration namespace
is *not* imported automatically into every aspx page.

I hope this is clearer to you now.


Not really. I guess I'm a little dense. :^)

This, of course, compiles just fine:
Dim sConnString As String = System.Configuration.ConfigurationManager.AppSetti ngs("dsn")

and this (because System is imported by default in VB)
Dim sConnString As String = Configuration.ConfigurationManager.AppSettings("ds n")

and if I import System.Configuation I would just use:
Imports System.Configuration
Dim sConnString As String = ConfigurationManager.AppSettings("dsn")

but now this won't compile: ?
Imports System.Configuration
Dim sConnString As String = Configuration.ConfigurationManager.AppSettings("ds n")
Error: 'System' is not a member of 'System.Configuration.Configuration'

And I can't get this line to compile at all...?
Dim sConnString As String =
System.Configuration.System.Configuration.Configur ationManager.AppSettings("dsn")

Error: 'System' is not a member of 'Configuration'

I don't think I will ever completely understand this. Don't bother trying to explain it
to me again, I'm hopeless. :^)
The thing is that the ConfigurationManager class isn't meant to be used
just to read a key and insert the key's string value into a connection.

It's meant to be used to *modify* configuration files.

If you just want to read a value in web.config, use :
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];


Interesting, never heard that metioned before. I thought we were expected to stop using
System.Configuration.ConfigurationSettings.AppSett ings?

Greg

Nov 19 '05 #11
re:
I'm reading a value from App.config
Isn't System.Configuration.ConfigurationSettings.AppSett ings
hard-wired to read from web.config if you're writing a web application?

Are you talking about a Windows Forms app.config ?

Windows applications in the .NET Framework use
the name app.config by default for their configuration file.

Web applications use web.config by default for the configuration file.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Mike L" <Ca***@nospam.nospam> wrote in message
news:D6**********************************@microsof t.com... I'm reading a value from App.config
My project is a C# 2005 win form application.

Should I ignore the warring messages for "string sConnString =
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];" ?

"Juan T. Llibre" wrote:
Just import system.configuration and use :
string sConnString = System.Configuration.ConfigurationManager.AppSetti ngs["dsn"];

The thing is that the ConfigurationManager class isn't meant to be used
just to read a key and insert the key's string value into a connection.

It's meant to be used to *modify* configuration files.

If you just want to read a value in web.config, use :
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Mike L" <Ca***@nospam.nospam> wrote in message
news:F1**********************************@microsof t.com...
> 'System' does not exist in the namespace 'System.Configuration'
>
> I added C:\Windows\Microsoft.NET\Framework\v2.0.50727\Syst em.configuration.dll
> I also added using System.Configuration;
>
> Here is the line of code it errors on.
> string sConnString =
> System.Configuration.System.Configuration.Configur ationManager.AppSettings["dsn"];
>
>
> For now, I'm staying with ConfigurationSettings and live with the warnings.
> string sConnString =
> System.Configuration.ConfigurationSettings.AppSett ings["dsn"];
>
>
> "Juan T. Llibre" wrote:
>
>> Hi, Greg.
>>
>> re:
>> > Can anyone explain?
>>
>> System.Configuration.ConfigurationSettings.AppSett ings
>> is a class in the System.Configuration namespace in system.dll.
>>
>> System.Configuration.ConfigurationManager.AppSetti ngs isn't.
>>
>> See :
>>
>> http://www.asp.net/QUICKSTART/util/c....Configuration
>>
>> Configuration.ConfigurationManager is a class which resides in
>> System.Configuration (in system.configuration.dll), not in system.dll
>> which is where Configuration.ConfigurationSettings.AppSettings resides.
>>
>> It's a bit confusing because the System.Configuration first names seem the same,
>> but -just like you do with people- you need a first name *and* a last name
>> to identify individuals.
>>
>> The System.Configuration class in System.dll is really System.System.Configuration
>> ( notice the *two* "system" in the name ) but we don't have to identify the base
>> namespace because it's automatically imported in all aspx pages.
>>
>> If you want to use the ConfigurationManager.AppSettings class which is
>> a part of system.configuration.dll without importing the namespace,
>> you'll need to use its full name :
>>
>> System.Configuration.System.Configuration.Configur ationManager.AppSettings
>>
>> That because the System.Configuration.System.Configuration namespace
>> is *not* imported automatically into every aspx page.
>>
>> I hope this is clearer to you now.
>>
>>
>>
>> Juan T. Llibre, ASP.NET MVP
>> ASP.NET FAQ : http://asp.net.do/faq/
>> ASPNETFAQ.COM : http://www.aspnetfaq.com/
>> Foros de ASP.NET en Español : http://asp.net.do/foros/
>> ======================================
>> "Greg Burns" <bl*******@newsgroups.nospam> wrote in message
>> news:ut*************@TK2MSFTNGP15.phx.gbl...
>> > FYI, to actually use System.Configuration.ConfigurationManager.AppSetti ngs in 2.0
>> > you
>> > must add a reference to System.configuration.dll. (I wasted a lot of time trying
>> > to
>> > figure that out).
>> >
>> > This is not necessary to do to use
>> > System.Configuration.ConfigurationSettings.AppSett ings and I not sure why. Can
>> > anyone
>> > explain?
>> >
>> > Greg
>> >
>> > "Jaime Stuardo" <js******@manquehue.net> wrote in message
>> > news:uM*************@TK2MSFTNGP14.phx.gbl...
>> >> Hi Patrick..
>> >>
>> >> I cannot do that since this method is in a DLL that is referenced by the ASP.NET
>> >> project. When I use AppSettings from the component, I receive a null. However I
>> >> think I
>> >> could use what you suggested if I have public DataSet GetCategories(String
>> >> connectionStr).
>> >>
>> >> By the way, I use ASP.NET 2.0 and in this version
>> >> ConfigurationSettings.AppSettings
>> >> is
>> >> reported as obsolete. I should use ConfigurationManager.AppSettings instead.
>> >>
>> >> Jaime
>> >>
>> >> "Patrick.O.Ige" <na********@hotmail.com> wrote in message
>> >> news:em**************@TK2MSFTNGP12.phx.gbl...
>> >>> if you have it in Web.Config like:-
>> >>> <add key="ConnectionString" value="server=(local);database=YourDB;integrated
>> >>> security=true;" />
>> >>> Then in you app do:-
>> >>> myconnection = New
>> >>> SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
>> >>> Is that what you are looking for.
>> >>> Patrick
>> >>>
>> >>>
>> >>> "Jaime Stuardo" <js******@manquehue.net> wrote in message
>> >>> news:ef**************@TK2MSFTNGP14.phx.gbl...
>> >>>> Hi all..
>> >>>>
>> >>>> I have created a business logic component that is used from my ASP.NET
>> >>>> webform. It works, but connection string to the database is hard coded, as
>> >>>> in this method :
>> >>>>
>> >>>> public DataSet GetCategories()
>> >>>> {
>> >>>> SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
>> >>>> Catalog=XXXX;User ID=X;Password=Y");
>> >>>> SqlDataAdapter adapter = new SqlDataAdapter("SELECT CAT_ID, CAT_NOM
>> >>> FROM
>> >>>> CATEGORIA ORDER BY CAT_NOM", conn);
>> >>>> DataSet ds = new DataSet();
>> >>>> adapter.Fill(ds);
>> >>>> return ds;
>> >>>> }
>> >>>>
>> >>>> I need to know what is the best way to pass the connection string that is
>> >>>> present in the web.config file. I tried using a constructor in that
>> >>> business
>> >>>> class but with no success. Also I have read that ObjectDataSource uses
>> >>>> stateless components so I think the usage of properties isn't allowed
>> >>> here.
>> >>>>
>> >>>> The question is, the only solution I could implement is passing the
>> >>>> connection string as a parameter to GetCategories? is there another one?
>> >>>> Since this method resides in a DLL, I cannot use ConnectionManager class
>> >>> to
>> >>>> access web.config file.
>> >>>>
>> >>>> Thanks a lot
>> >>>> Jaime
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>>
>>
>>


Nov 19 '05 #12

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Isn't System.Configuration.ConfigurationSettings.AppSett ings
hard-wired to read from web.config if you're writing a web application?

Are you talking about a Windows Forms app.config ?

Windows applications in the .NET Framework use
the name app.config by default for their configuration file.

Web applications use web.config by default for the configuration file.
ACK.

But what about his question?
Should I ignore the warring messages for "string sConnString =
System.Configuration.ConfigurationSettings.AppSet tings["dsn"];" ?


Sounds like you are saying you should ingore the warnings and continue to
use ConfigurationSettings.AppSettings for reading from web.config and
app.config files. This is the first time I've heard somebody suggest that.
I was under the impressions that ConfigurationSettings.AppSettings was
obsolete and should be avoided in favor of the new
ConfigurationManager.AppSettings.

Greg


Nov 19 '05 #13
re:
ConfigurationSettings.AppSettings was obsolete and should be avoided in favor of the new
ConfigurationManager.AppSettings
It is *deprecated*, not obsolete.

You can *still* read web.config values with ConfigurationSettings.AppSettings.

At some point in the future, though, it will stop working. (.Net Framework 3.0 ?)

re: Sounds like you are saying you should ingore the warnings and continue to use
ConfigurationSettings.AppSettings for reading from web.config and app.config files.
Like I said, app.config is for Windows Forms,
and web.config is for web applications.

He said he was using app.config, but this is a web applications newsgroup.

If he is getting warnings when he uses app.config in a web application,
then he should, simply, only use app.config for Windows applications,
and use web.config for web applications.

Otherwise, if he is using app.config in a Windows Application,
he should post to the right newsgroup for Windows apps, which is :

microsoft.public.dotnet.framework.windowsforms or any of its subgroups.

Is that clearer now ?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:eD**************@TK2MSFTNGP09.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Isn't System.Configuration.ConfigurationSettings.AppSett ings
hard-wired to read from web.config if you're writing a web application?
re: Are you talking about a Windows Forms app.config ?

Windows applications in the .NET Framework use
the name app.config by default for their configuration file.

Web applications use web.config by default for the configuration file.


ACK.

But what about his question?
Should I ignore the warring messages for "string sConnString =
System.Configuration.ConfigurationSettings.AppSe ttings["dsn"];" ?


Sounds like you are saying you should ingore the warnings and continue to use
ConfigurationSettings.AppSettings for reading from web.config and app.config files.
This is the first time I've heard somebody suggest that. I was under the impressions
that ConfigurationSettings.AppSettings was obsolete and should be avoided in favor of
the new ConfigurationManager.AppSettings.

Greg

Nov 19 '05 #14
inline

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
re:
ConfigurationSettings.AppSettings was obsolete and should be avoided in
favor of the new ConfigurationManager.AppSettings
It is *deprecated*, not obsolete.


The warning VS gives is "obsolete".
You can *still* read web.config values with
ConfigurationSettings.AppSettings.

At some point in the future, though, it will stop working. (.Net Framework
3.0 ?)

re:
Sounds like you are saying you should ingore the warnings and continue to
use ConfigurationSettings.AppSettings for reading from web.config and
app.config files.
Like I said, app.config is for Windows Forms,
and web.config is for web applications.


Yes, of course.
He said he was using app.config, but this is a web applications newsgroup.

If he is getting warnings when he uses app.config in a web application,
then he should, simply, only use app.config for Windows applications,
and use web.config for web applications.


You get the warning in both Windows apps and Web apps when you use
ConfigurationSettings.AppSettings

Greg

Nov 19 '05 #15
re:
The warning VS gives is "obsolete".
It's still deprecated, not obsolete.

When something is obsolete, it doesn't works any more.
When something is deprecated, it still works.

re: You get the warning in both Windows apps and Web apps when you use
ConfigurationSettings.AppSettings
I *never* get that warning neither in 1.1 nor in 2.0 web apps.
Maybe I'm just lucky ?

See an example at my test application, configured for ASP.NET 2.0:
http://asp.net.do/test/checkAppSettings.aspx

All that page has is :

checkAppSettings.aspx :
-------------------------
<script language="vb" runat="server">
Sub Page_Load()
Dim miSELECT as String = (ConfigurationSettings.AppSettings("selectDocs"))
setting.text = miSELECT
Dim miVersion as String = System.Environment.Version.ToString()
version.Text = "This application is running under ASP.NET version " & miVersion
End Sub
</script>
<html>
<head><title>Retrieve AppSetting key and ASP.NET Version</title></head>
<body>
<asp:label id="setting" runat="server" /><br/>
<asp:label id="version" runat="server" /><br/>
</body>
</html>
------------------------

The key in web.config reads like this :

<appSettings>
<add key="selectDocs" value="SELECT * FROM documents WHERE thereisdata ORDERBY
CreationDate DESC"/>
</appSettings>

Why am I not getting any warnings,
and why does that page compile OK if, as you say :
You get the warning in both Windows apps and Web apps when you use
ConfigurationSettings.AppSettings
?


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl... inline

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
re:
ConfigurationSettings.AppSettings was obsolete and should be avoided in favor of the
new ConfigurationManager.AppSettings


It is *deprecated*, not obsolete.


The warning VS gives is "obsolete".
You can *still* read web.config values with ConfigurationSettings.AppSettings.

At some point in the future, though, it will stop working. (.Net Framework 3.0 ?)

re:
Sounds like you are saying you should ingore the warnings and continue to use
ConfigurationSettings.AppSettings for reading from web.config and app.config files.


Like I said, app.config is for Windows Forms,
and web.config is for web applications.


Yes, of course.
He said he was using app.config, but this is a web applications newsgroup.

If he is getting warnings when he uses app.config in a web application,
then he should, simply, only use app.config for Windows applications,
and use web.config for web applications.


You get the warning in both Windows apps and Web apps when you use
ConfigurationSettings.AppSettings

Greg

Nov 19 '05 #16

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...
re:
The warning VS gives is "obsolete".
It's still deprecated, not obsolete.

When something is obsolete, it doesn't works any more.
When something is deprecated, it still works.


Okay, okay. :)

re:
You get the warning in both Windows apps and Web apps when you use
ConfigurationSettings.AppSettings


I *never* get that warning neither in 1.1 nor in 2.0 web apps.
Maybe I'm just lucky ?


We'll you definately would never see it in 1.1, because this is a compiler
warning in VS 2005 for .NET 2.0.

No clue, why you don't see it in VS 2005. I see it in both my code bedhind
and in-line in the .aspx if I do like your example.

You must be lucky. :)

Did you perhaps turn off this warning in an option somewhere?

Greg
Nov 19 '05 #17
re:
We'll you definately would never see it in 1.1, because this is a compiler warning in VS
2005 for .NET 2.0.
It's a 2.0 app.

However, VS 2005, or the .Net compiler team, may be schizophrenic.

On the one hand VS 2005 says that a class is "obsolete",
but it runs OK and it compiles without errors.

Maybe the documentation guys flubbed this one ?

What the warning message should say is that the class
has been "deprecated", but that it compiles and runs OK.

When something is obsolete, it doesn't work any more.
When something is deprecated, it still works.

Not your fault, and not my fault, but I tend to take
these documentation flubs with a little grain of salt.

;-)

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...
re:
The warning VS gives is "obsolete".


It's still deprecated, not obsolete.

When something is obsolete, it doesn't works any more.
When something is deprecated, it still works.


Okay, okay. :)

re:
You get the warning in both Windows apps and Web apps when you use
ConfigurationSettings.AppSettings


I *never* get that warning neither in 1.1 nor in 2.0 web apps.
Maybe I'm just lucky ?


We'll you definately would never see it in 1.1, because this is a compiler warning in VS
2005 for .NET 2.0.

No clue, why you don't see it in VS 2005. I see it in both my code bedhind and in-line
in the .aspx if I do like your example.

You must be lucky. :)

Did you perhaps turn off this warning in an option somewhere?

Greg

Nov 19 '05 #18
Interesting read

http://www.gotdotnet.com/team/change...soletefaq.aspx

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl...
re:
We'll you definately would never see it in 1.1, because this is a
compiler warning in VS 2005 for .NET 2.0.


It's a 2.0 app.

However, VS 2005, or the .Net compiler team, may be schizophrenic.

On the one hand VS 2005 says that a class is "obsolete",
but it runs OK and it compiles without errors.

Maybe the documentation guys flubbed this one ?

What the warning message should say is that the class
has been "deprecated", but that it compiles and runs OK.

When something is obsolete, it doesn't work any more.
When something is deprecated, it still works.

Not your fault, and not my fault, but I tend to take
these documentation flubs with a little grain of salt.

;-)

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================

Nov 19 '05 #19
Thanks, Greg.

Interesting, indeed.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Interesting read

http://www.gotdotnet.com/team/change...soletefaq.aspx

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl...
re:
We'll you definately would never see it in 1.1, because this is a compiler warning in
VS 2005 for .NET 2.0.


It's a 2.0 app.

However, VS 2005, or the .Net compiler team, may be schizophrenic.

On the one hand VS 2005 says that a class is "obsolete",
but it runs OK and it compiles without errors.

Maybe the documentation guys flubbed this one ?

What the warning message should say is that the class
has been "deprecated", but that it compiles and runs OK.

When something is obsolete, it doesn't work any more.
When something is deprecated, it still works.

Not your fault, and not my fault, but I tend to take
these documentation flubs with a little grain of salt.

;-)

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================


Nov 19 '05 #20

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Arsen Vladimirskiy | last post: by
3 posts views Thread by Simon Harvey | last post: by
1 post views Thread by Mythran | last post: by
25 posts views Thread by Stuart Hilditch | last post: by
4 posts views Thread by Jeff | last post: by
3 posts views Thread by alaytin | last post: by
16 posts views Thread by MS newsgroup | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.